home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2a.lha / p4-1.2a / doc / p4.info < prev    next >
Text File  |  1992-11-07  |  93KB  |  2,625 lines

  1. Info file: p4.info,    -*-Text-*-
  2. produced by latexinfo-format-buffer
  3. from file: p4.tex
  4.  
  5.  
  6.  
  7. 
  8. File: p4.info  Node: Top, Prev: (dir), Up: (dir), Next: Introduction
  9.  
  10.  
  11. * Menu:
  12.  
  13. * Introduction::        
  14. * Structure of the Distribution Directory::
  15. * Installing p4::       
  16. * Getting Started::     
  17. * Specifying Processes in the Procgroup File::
  18. * Developing a Simple p4 Program::
  19. * Command-Line Arguments::
  20. * The p4 Function Library::
  21. * p4 Functions for Managing Processes and Clusters::
  22. * Functions for Message Passing::
  23. * Functions for Shared Memory::
  24. * Functions for Timing p4 Programs::
  25. * Functions for Debugging p4 Programs::
  26. * Miscellaneous Functions::
  27. * Fortran Interface::   
  28. * Faster Startup with the Secure Server::
  29. * Utilities for Managing a p4 Session::
  30. * Creating Logfiles for Upshot::
  31. * Machine-Specific Notes::
  32. * Some Common Problems and their Solutions::
  33. * Concept Index::       
  34. * Function Index::      
  35.  
  36.  
  37. 
  38. File: p4.info  Node: Introduction, Prev:     , Up: Top, Next: Structure of the Distribution Directory
  39.  
  40.  
  41. Introduction
  42. ============
  43.  
  44.  
  45. P4 is a library of macros and subroutines developed at Argonne National
  46. Laboratory for programming a variety of parallel machines.  Its
  47. predecessor was the m4-based "Argonne macros" system described in the
  48. Holt, Rinehart, and Winston book {Portable Programs for Parallel
  49. Processors}, by Lusk, Overbeek, et al., from which p4 takes its
  50. name[lusk-overbeek:p4-book].  The current p4 system maintains the
  51. same basic computational models described there (monitors for the
  52. shared-memory model, message-passing for the distributed-memory model,
  53. and support for combining the two models) while significantly increasing
  54. ease and flexibility of use. *Note Getting Started:: for a simple example.
  55.  
  56. P4 is intended to be portable, simple to install and use, and efficient.  It
  57. can be used to program networks of workstations, advanced parallel
  58. supercomputers like the Intel Touchstone Delta and the Alliant Campus
  59. HiPPI-based system, and single shared-memory multiprocessors.  It has
  60. currently been installed on the following list of machines: Sequent Symmetry
  61. (Dynix and PTX), Encore Multimax, Alliant FX/8, FX/800, and FX/2800, Cray
  62. X/MP, Sun, NeXT, DEC, Silicon Graphics, HP, and IBM RS6000 workstations,
  63. Stardent Titan, BBN GP-1000 and TC-2000, Intel IPSC/860, Intel Touchstone
  64. Delta, Alliant Campus, and Thinking Machines' CM-5.  It will soon be ported to
  65. to the Intel Paragon.  It is not difficult to port to new systems.  Although
  66. p4 tries to be completely portable, there are a small number of
  67. specific exceptions (*Note Machine-Specific Notes::) that may need to be taken
  68. into account on a given machine.
  69.  
  70. You can obtain the complete distribution of p4 by anonymous ftp from
  71. `info.mcs.anl.gov'.  Take the file `p4.tar.Z' from the
  72. directory `pub/p4'.  The distribution contains all source code,
  73. installation instructions, this reference manual, and a collection of
  74. examples in both C and Fortran. `Alog' is included in the
  75. distribution with p4.  The file `upshot.tar.Z' contains display
  76. facilities that can be used with p4 and other systems.
  77.  
  78. To ask questions about p4, report bugs, contribute examples, etc., you can
  79. send mail to `p4@mcs.anl.gov'.
  80.  
  81. The current release is version 1.2.  You can check which version of the source
  82. code you have by looking at the file `lib/p4_patchlevel.h' in the
  83. distribution.  You can check which version of the object code you have linked
  84. to by running any p4 program with the command-line option `-p4version'
  85. (*Note Command-Line Arguments::).
  86.  
  87. Salient features of the current release of p4 include: 
  88.    * `xdr' support for heterogeneous networks
  89.    * manual enhanced and converted to latex format
  90.    * Emacs info version of the manual for on-line help
  91.    * SYSV IPC support added for several machines (for shared-memory
  92.        multiprocessing on workstations that support multiple processors)
  93.    * instrumentation added for automatic logging/tracing
  94.    * automatic or user control of message-passing/buffer-management
  95.    * high-resolution clock support for several machines
  96.    * error/interrupt handling
  97.    * an optional secure server for quick startup
  98.  
  99.  
  100. A useful companion system is the `alog/upshot' logging and X-based trace
  101. examination facility.  (*Note Creating Logfiles for Upshot::.)
  102.  
  103.  
  104. 
  105. File: p4.info  Node: Structure of the Distribution Directory, Prev: Introduction, Up: Top, Next: Installing p4
  106.  
  107.  
  108. Structure of the Distribution Directory
  109. =======================================
  110.  
  111.  
  112.  
  113. The p4 source code distribution contains the following files and
  114. subdirectories:
  115.  
  116.  
  117. Makefile     
  118.       The makefile for making the p4 system, doing the installation,
  119.        and making makefiles for user applications.
  120. OPTIONS     
  121.       A file controlling various compile-time options, such as
  122.        whether System V shared-memory operations are to be enabled, whether system
  123.        debug message printing is to be enabled, and whether automatic
  124.        instrumentation of p4 operations for the `upshot' logging and tracing
  125.        program is to be done.
  126. README     
  127.       General instructions.
  128. alog     
  129.       Source code for the ALOG tracing package.
  130. bin     
  131.       Scripts for starting and killing servers, killing runaway p4
  132.        processes, merging `upshot' logfiles, and other useful utilities.
  133. contrib     
  134.       Examples contributed by p4 users.
  135. contrib_f     
  136.       Fortran examples contributed by users.
  137. doc     
  138.       The man page, together with this manual and supporting files.
  139. include     
  140.       The include directory for making p4 applications.  Most of
  141.        these are (hard) links into the `lib' directory.
  142. lib     
  143.       The source code for the p4 system.
  144. lib_f     
  145.       The Fortran interface for p4.  
  146. messages     
  147.       A basic set of message-passing examples in C.
  148. messages_f     
  149.       A basic set of message-passing examples in Fortran.
  150. monitors     
  151.       A basic set of shared-memory examples in C.
  152. servers     
  153.       The secure and insecure servers.
  154. usc     
  155.       The portable microsecond clock routines.
  156. util     
  157.       Assorted supporting files, particularly for making the p4
  158.        distribution. 
  159.  
  160.  
  161. 
  162. File: p4.info  Node: Installing p4, Prev: Structure of the Distribution Directory, Up: Top, Next: Getting Started
  163.  
  164.  
  165. Installing p4
  166. =============
  167.  
  168.  
  169.  
  170. In this section we describe how to install the p4 library, either for
  171. your own personal use or for the use of everyone at your site.  In the
  172. first case you do not need any super-user privileges.  In the second
  173. case, you may or may not, depending on how things are configured at
  174. your site.  We also describe how to install and run the examples that
  175. come with p4, the online help system (this manual as an emacs info-file)
  176. and how to build a working directory for your own programs yet share
  177. the installed copy of p4 with other users.
  178.  
  179.  
  180. * Menu:
  181.  
  182. * Installing the p4 System::
  183. * Installing the Documentation::
  184. * Examples included with the Distribution::
  185.  
  186.  
  187. 
  188. File: p4.info  Node: Installing the p4 System, Prev:     , Up: Installing p4, Next: Installing the Documentation
  189.  
  190.  
  191. Installing the p4 System
  192. ------------------------
  193.  
  194.  
  195. To build p4, position yourself in the `p4' directory and type:
  196.      make all MACHINE=<machine>
  197.  
  198. where <machine> is one of the machine names listed in
  199. `p4/util/machines', currently:
  200.  
  201.  
  202. SUN     
  203.       Sun-3, Sun386i, Sparc-1, or Sparc-2 workstations
  204.      
  205. HP     
  206.       HP workstations
  207.      
  208. DEC5000     
  209.       Dec 5000 workstations
  210.      
  211. NEXT     
  212.       68030- or 68040-based NeXT workstations
  213.      
  214. RS6000     
  215.       IBM RS 6000 series workstations
  216.      
  217. IBM3090     
  218.       IBM 3090 running IBM's version of UNIX, AIX
  219.      
  220. BALANCE     
  221.       Sequent Symmetry shared-memory multiprocessor
  222.      
  223. SYMMETRY     
  224.       Sequent Symmetry shared-memory multiprocessor
  225.      
  226. SYMMETRY_PTX     
  227.       Sequent Symmetry shared-memory multiprocessor PTX OS
  228.      
  229. MULTIMAX     
  230.       Encore Multimax shared-memory multiprocessor
  231.      
  232. GP_1000     
  233.       BBN GP-1000
  234.      
  235. TC_2000     
  236.       BBN TC-2000
  237.      
  238. TC_2000_TCMP     
  239.       BBN TC-2000 with the TCMP message-passing library
  240.      
  241. IPSC860     
  242.       Intel IPSC/860 (nodes only)
  243.      
  244. IPSC860_SOCKETS     
  245.       Intel IPSC/860 with socket libraries on the nodes
  246.      
  247. DELTA     
  248.       Intel DELTA 
  249.      
  250. TITAN     
  251.       Stardent Titan
  252.      
  253. SGI     
  254.       Silicon Graphics workstations
  255.      
  256. CRAY     
  257.       Cray X/MP
  258.      
  259. FX8     
  260.       Alliant FX/8
  261.      
  262. FX2800     
  263.       Alliant FX/2800 or FX/800
  264.      
  265. FX2800_SWITCH     
  266.       Alliant FX/2800 or FX/800, with CAMPUS HiPPI switch
  267.      
  268. KSR     
  269.       Kendall Square KSR-1
  270.      
  271. CM-5     
  272.       Thinking Machines' CM-5
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. For example:
  280.      make all MACHINE=SYMMETRY
  281.  
  282. The `all' is optional, for example
  283.      make MACHINE=SEQUENT
  284.  
  285. This will create a machine-dependent `Makefile' in each subdirectory,
  286. make the p4 library, and compile and link a subset of the examples.
  287.  
  288. To add a new machine type, or to change the characteristic parameters
  289. associated with an existing one, you can edit the file 
  290. `p4/util/defs.all'.
  291.  
  292. To save disk space, various intermediate object files can be removed with
  293.      make clean
  294.  
  295. The system can be restored to its original, machine-independent state with
  296.      make realclean
  297.  
  298. Note that this removes the machine-dependent Makefiles in each directory, so
  299. the operation is not idempotent.
  300.  
  301. It is also possible to install (or clean) only some of the directories:
  302.      make all MACHINE=SUN DIRS=messages
  303.      make clean DIRS='monitors messages'
  304.  
  305. To install only the Makefiles in all subdirectories, use:
  306.      make makefiles MACHINE=<machine>
  307.  
  308. directory everything that is needed to compile and link p4 programs, 
  309. do:
  310.  
  311.      make install INSTALLDIR=<dir>
  312.  
  313. minimal set of directories, copy the relevant `.a' and `.h' files
  314. into it, and test the installation by mking a small set of examples.
  315.  
  316.  
  317. *Note Getting Started:: for instructions on how to run some example
  318. programs after you have installed p4.
  319. 
  320. File: p4.info  Node: Installing the Documentation, Prev: Installing the p4 System, Up: Installing p4, Next: Examples included with the Distribution
  321.  
  322.  
  323. Installing the Documentation
  324. ----------------------------
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. The directory `p4/doc' contains this manual as well as files that
  332. require installation.  This manual was prepared with the
  333. `latexinfo' package from GNU emacs; thus it can be made available online
  334. through `info'.  The files in `p4/doc' are:
  335.  
  336. p4.tex     
  337.       the latex source for this manual, which uses the latexinfo style
  338.      
  339. latexinfo.sty     
  340.       the sytle file needed to latex this manual
  341.      
  342. p4.info     
  343.       the `info' version of this manual, ready to be put
  344.      into the directory where `info' files are kept at your site.  Check
  345.      the value of your `emacs' variable INFO-DIRECTORY.
  346.      
  347. p4.txt     
  348.       plain ascii text of the manual, in case nothing else works.
  349.      
  350. p4.1     
  351.       unix man page for the p4 library
  352.      
  353. p4f.1     
  354.       unix man page for the Fortran interface to p4
  355.      
  356.  
  357.  
  358. The Postscript version of this manual is available by anonymous `ftp'
  359. from `info.mcs.anl.gov', in the directory `pub/p4'.  The file to
  360. get (in binary mode) is `p4man.ps.Z'.
  361.  
  362. 
  363. File: p4.info  Node: Examples included with the Distribution, Prev: Installing the Documentation, Up: Installing p4, Next:     
  364.  
  365.  
  366. Examples included with the Distribution
  367. ---------------------------------------
  368.  
  369.  
  370.  
  371. A good way to see how various p4 functions are used is to look at the example
  372. programs included in the distribution.  The `p4/monitors' directory
  373. contains shared-memory examples written in C that use monitors, including one
  374. instrumented with ALOG.  The `p4/messages' subdirectory contains
  375. message-passing examples written in C.  The programs in `p4/messages_f'
  376. are Fortran message-passing examples, and the `p4/contrib' and
  377. `p4/contrib_f' directories contain a number of miscellaneous examples
  378. contributed by users.  In each directory there is a `README' that
  379. describes the individual examples.
  380.  
  381. 
  382. File: p4.info  Node: Getting Started, Prev: Installing p4, Up: Top, Next: Specifying Processes in the Procgroup File
  383.  
  384.  
  385. Getting Started
  386. ===============
  387.  
  388.  
  389.  
  390. The easiest way to get started with p4 is to play with some of the
  391. sample programs provided with the system.
  392.  
  393. * Menu:
  394.  
  395. * A Message-Passing Example::
  396. * Analysis of the Program::
  397.  
  398.  
  399. 
  400. File: p4.info  Node: A Message-Passing Example, Prev:     , Up: Getting Started, Next: Analysis of the Program
  401.  
  402.  
  403. A Message-Passing Example
  404. -------------------------
  405.  
  406.  
  407. We will begin with a message-passing example in the sub-directory named
  408. `p4/messages'.  The code for the program is in the files `sr_test.c'
  409. and `sr_user.h'.
  410.  
  411.  
  412.  
  413. Program Description
  414. -------------------
  415.  
  416.  
  417. As the name implies, this program is an example of p4's send/receive
  418. functionality.  Briefly, it is a simple program that runs a master
  419. process and some slave processes.  The master and the set of slaves
  420. form a ring of processes in which the master reads a message from stdin
  421. and sends a copy of the message to the first slave, which passes it on;
  422. the last slave passes the message back to the master.  If the master
  423. receives an undamaged copy of the message, it assumes that all went
  424. well, and reads another message.  Note that the ring of processes is a
  425. logical structure in which each process assumes that its
  426. predecessor in the ring is the process with the next lower id, and
  427. its successor is the process with the next higher id.  The master
  428. has id 0 (zero) and has the process with the largest id as its
  429. predecessor.
  430.  
  431.  
  432. 
  433. File: p4.info  Node: Analysis of the Program, Prev: A Message-Passing Example, Up: Getting Started, Next:     
  434.  
  435.  
  436. Analysis of the Program
  437. -----------------------
  438.  
  439.  
  440. The first executable p4 statement in a program should be:
  441.      p4_initenv(&argc,argv); 
  442.  
  443. This initializes the p4 system and allows p4 to extract any command
  444. line arguments passed to it, e.g. debugging parameters.  
  445.  
  446. Similarly, the last executable p4 statement in a program should be:
  447.      p4_wait_for_end(); 
  448.  
  449. This waits for termination of p4 processes and performs some cleanup
  450. operations.
  451.  
  452. The procedure `p4_get_my_id' returns the unique integer id assigned
  453. to the calling process by p4.
  454.  
  455. The statement:
  456.      p4_create_procgroup();
  457.  
  458. reads a procgroup file that the user builds and creates the set of
  459. slaves described in that file.  Obviously this statement must be
  460. executed before any slaves can be assumed to exist.  This procedure
  461. is the method you must use to create processes that do message-passing.
  462.  
  463. The procedure `p4_clock' returns an integer that represents
  464. wall-clock time in milliseconds.  It is typically used to retrieve the
  465. time before and after some work, the difference representing the time to
  466. do that work.  Note that there is also a `p4_ustimer' that is useful on
  467. those machines that support a microsecond timer.
  468.  
  469. The procedures `p4_send' and `p4_sendr' are two of several 
  470. p4 procedures that are available for sending messages to other processes.
  471. They take as arguments the message type, the id of the "to" process,
  472. the address of the message, and the message length.
  473.  
  474. The procedure `p4_recv' receives a message from another process and
  475. sets the values of all four parameters.  `P4_recv' will automatically
  476. retrieve a buffer in which to place a received message, thus
  477. `p4_msg_free' may be called to free that buffer when it is no longer
  478. needed.
  479.  
  480. The procedure `p4_num_total_slaves' is one of several procedures that
  481. the user can invoke to determine information about the current execution.
  482.  
  483. To run this program, you need to create a procgroup file that describes
  484. where all slave processes are to be executed 
  485. (*Note Specifying Processes in the Procgroup File::).  We will assume that
  486. you have an example procgroup file (named `procgroup') in the 
  487. `p4/messages' directory, and can run `sr_test' by merely typing:
  488.      sr_test
  489.  
  490. If the procgroup file is elsewhere, then you must type:
  491.      sr_test -pg  {pathname_of_procgroup_file}
  492.  
  493.  
  494. Another example that is made by default is the program `systest'.  It
  495. tests a number of the message-passing features of p4.
  496.  
  497. 
  498. File: p4.info  Node: Specifying Processes in the Procgroup File, Prev: Getting Started, Up: Top, Next: Developing a Simple p4 Program
  499.  
  500.  
  501. Specifying Processes in the Procgroup File
  502. ==========================================
  503.  
  504.  
  505.  
  506. The procgroup file is the only portion of the interface that is very
  507. likely to change through multiple versions of p4.  As new architectures
  508. are supported, it is hoped that we can merely alter the procgroup file
  509. format to reflect any new features.  (Of course new procedure calls may 
  510. also be required, but existing procedure calls will remain unchanged 
  511. when possible).
  512.  
  513. The current format of a procgroup file is as follows:
  514.      local n [full_path_name] [loginname]
  515.      remote_machine n full_path_name [loginname]
  516.      .
  517.      .
  518.      .
  519.  
  520.  
  521. On cube and mesh architectures, the program is started via some
  522. special command executed from the host machine.  In such cases, the
  523. procgroup file name can be specified to the special command line along
  524. with the program name (see for example the `runcube' and `rundelta'
  525. shell scripts in the `p4/messages' subdirectory).  In those cases 
  526. where no special command is required, no special handling is required 
  527. for the procgroup filename.
  528.  
  529. The first line of a procgroup file must be "local n" where n is the
  530. number of slave processes that are in the same cluster as the master.
  531. The full path name on the "local" line is ignored on machines other
  532. than cube and mesh machines.  The subsequent lines contain either
  533. three or four fields:
  534.   1. the name of a remote machine on which slave processes are to be created.
  535.   2. the number of slaves that are to be created on that machine, 
  536.      i.e. be in the same cluster (note that on machines that support it, 
  537.      the processes in a cluster will share memory)
  538.   3. the full path name of the executable slave program
  539.   4. optionally, the user login name on the remote machine, if different from 
  540.      that on the host machine.
  541.  
  542.  
  543. As an example, let's assume that you have a network of three Sun 
  544. workstations named sun1, sun2, and sun3.  We will also assume that you 
  545. are working on sun1 and plan to run a master process there.  
  546. If you would like to run one process on each of the other Suns, then you 
  547. might code a procgroup file that looks like:
  548.  
  549.          # start one slave on each of sun2 and sun3
  550.          local 0 
  551.          sun2  1  /home/mylogin/p4pgms/sr_test
  552.          sun3  1  /home/mylogin/p4pgms/sr_test
  553.  
  554.  
  555. Lines beginning with `#' are comments.
  556.  
  557. Next, let's assume that you have a Sequent Symmetry (named symm) and an
  558. Encore Multimax (named mmax).  We will also assume that you are working
  559. on symm, and plan to run the master there.  If you would like to run
  560. two processes on symm (in addition to the master) and two on mmax, then 
  561. you might code a procgroup file that looks like:
  562.  
  563.          local 2 
  564.          mmax  2  /mmaxfs/mylogin/p4pgms/sr_test
  565.  
  566.  
  567. P4 also permits you to treat the symmetry as a remote machine even when 
  568. you are running the master there.  Thus, you might code a procgroup file 
  569. as follows:
  570.  
  571.          local 2 
  572.          symm  2  /symmfs/mylogin/p4pgms/sr_test
  573.          mmax  2  /mmaxfs/mylogin/p4pgms/sr_test
  574.  
  575.  
  576. In this example, there are seven processes running.  Five of the
  577. processes are on symm, including the master.  Two of the processes on
  578. symm are in the master's procgroup and two are running in a separate
  579. procgroup as if they were on a separate machine.  Of course, the last
  580. two are running on mmax.
  581.  
  582. Some notes about the contents of the procgroup file should be made at
  583. this point.  First, the value of `n' on the local line can be zero,
  584. i.e. the master may have no local slaves.  Second, the local machine
  585. may be treated as if it is a remote machine by merely entering it in
  586. some line as a remote machine.  Third, a single machine may be treated
  587. as multiple remote machines by having the same remote machine name
  588. entered on multiple lines in the procgroup file.  Fourth, if a single
  589. machine is listed multiple times, those processes specified on each
  590. line form a single cluster (share memory).  Fifth, the cluster size
  591. specified for a uniprocessor should be 1, because all slaves in a
  592. cluster are assumed to run in parallel and to share memory.
  593.  
  594. We refer to the original (master) process as the "big master".  The
  595. first process created in each cluster is the "remote master" or the
  596. "cluster master" for that cluster.  
  597. All p4-managed processes (see the procedure `p4_create_procgroup') 
  598. have unique integer id's beginning with 0.
  599. The processes within a cluster are numbered consecutively.
  600.  
  601.  
  602. 
  603. File: p4.info  Node: Developing a Simple p4 Program, Prev: Specifying Processes in the Procgroup File, Up: Top, Next: Command-Line Arguments
  604.  
  605.  
  606. Developing a Simple p4 Program
  607. ==============================
  608.  
  609.  
  610. The real fun associated with any computing environment arrives when you
  611. actually type in a program and run it yourself.  We will assume that
  612. you have successfully installed p4 on your own system and are ready to
  613. write a small program, compile it, and run it.
  614.  
  615. * Menu:
  616.  
  617. * A Minimal Example::   
  618. * A More Complicated Example::
  619.  
  620.  
  621. 
  622. File: p4.info  Node: A Minimal Example, Prev:     , Up: Developing a Simple p4 Program, Next: A More Complicated Example
  623.  
  624.  
  625. A Minimal Example
  626. -----------------
  627.  
  628.  
  629. We will start with a tiny program in which the slave processes do no work, and
  630. then expand its capabilities.  Edit a file called `p4simple.c' and type:
  631.  
  632.      
  633.          #include "p4.h"
  634.      
  635.          main(argc,argv)
  636.          int argc;
  637.          char **argv;
  638.          {
  639.              p4_initenv(&argc,argv);
  640.              if (p4_get_my_id() == 0)
  641.                  p4_create_procgroup();
  642.              slave();
  643.              p4_wait_for_end();
  644.          }
  645.      
  646.          slave()
  647.          {
  648.              printf("Hello from %d++",p4_get_my_id());
  649.          }
  650.      
  651.  
  652.  
  653. This is one of the simplest p4 programs that you can write.  Let's
  654. examine it.  The `#include "p4.h"' statement must appear in all
  655. programs that use any p4 features.  The procedure `p4_initenv'
  656. must be invoked before any other p4 procedures, and
  657. `p4_wait_for_end' must be invoked after all p4 processing is
  658. completed.  The `p4_get_my_id' returns a unique integer id for
  659. each process, beginning with 0.  The procedure
  660. `p4_create_procgroup' should only be invoked once (by process 0),
  661. and is responsible for creating all other processes.  The way in which
  662. `p4_create_procgroup' determines how many other processes there
  663. should be, and where they should run, will be discussed shortly.
  664.  
  665. All processes that this program executes invoke the slave procedure,
  666. including process 0.  Thus, in this program, the master process acts
  667. just like all other processes once it gets the environment
  668. established.
  669.  
  670. To understand how things get started, let's consider two separate
  671. situations.  In the first situation, all processes are running on a
  672. single machine.  Then, when process 0 starts, it executes the
  673. `p4_create_procgroup' procedure to start all other slaves.  The other
  674. slaves are started on the same machine by means of a UNIX {fork},
  675. and they immediately invoke a procedure named slave.  Thus, these local
  676. slaves do not ever execute the main procdure.
  677.  
  678. In the second situation, there may be slaves running both on the same
  679. machine as process 0, and slaves running on other machines as well.
  680. In this situation, the first slave running on a remote machine will
  681. need to execute the main procedure.  It will discover that it is not
  682. process 0.  However, as part of initialization, process 0 will
  683. direct it to fork any additional slaves required on the same machine.
  684.  
  685.  
  686. In some ways, the above example can be used a a prototype for all p4 programs,
  687. just by varying the content of the `slave' routine.  The routine name
  688. `slave' is built into p4 in order to enable the same code to be run on
  689. shared-memory machines via `fork' or on remote machines via `rsh'.
  690. Different wrappers are automatically put around the `slave' code.  These
  691. wrappers depend on the user code being called `slave'.  Thus your p4
  692. program must contain a subroutine called `slave' in order to link
  693. properly. 
  694.  
  695. 
  696. File: p4.info  Node: A More Complicated Example, Prev: A Minimal Example, Up: Developing a Simple p4 Program, Next:     
  697.  
  698.  
  699. A More Complicated Example
  700. --------------------------
  701.  
  702.  
  703. Now, let's make the slave process a little bit more interesting.  Let's
  704. assume that we have `nprocs' slaves with ids 
  705. 0, 1, 2, ... `nprocs' -1.  And, we want to write a program in which
  706. every process sends a single message to every other slave, and then
  707. receives a message from every other slave.  We might alter the code for
  708. the slave procedure to be the following:
  709.  
  710.          slave()
  711.          {
  712.              char *incoming, *msg = "hello";
  713.              int myid, size, nprocs, from, i, type;
  714.      
  715.              myid = p4_get_my_id();
  716.              nprocs = p4_num_total_ids();
  717.              for (i=0; i < nprocs; i++)
  718.              {
  719.                  if (i != myid)
  720.                      p4_send(100, i, msg, strlen(msg)+1);
  721.              }
  722.              for (i=0; i < nprocs - 1; i++)
  723.              {
  724.                  type = -1;
  725.                  from = -1;
  726.                  incoming = NULL;
  727.                  p4_recv(&type,&from,&incoming,&size);
  728.                  printf("%d received msg=:%s: from %d++",myid,incoming,from);
  729.                  p4_msg_free(incoming);
  730.              }
  731.          }
  732.  
  733.  
  734. This program demonstrates several features of p4's support for
  735. message-passing.  Before we get into the specifics however, let's
  736. examine the overall logic of the program.  Each process determines its
  737. own id and the total number of processes executing in this run
  738. (including process 0).  Then, in the first for-loop, each process sends
  739. a single message to each of the other processes.  Finally, in the
  740. second for-loop, each process receives a message from each of the other
  741. processes.
  742.  
  743. The `p4_send' call requires 4 arguments:
  744.    * a message type (arbitrarily chosen to be 100 here)
  745.    * the id of the process to receive the message
  746.    * the message itself
  747.    * the size of the message
  748.  
  749.  
  750. The use of `p4_recv' is slightly more complicated.  First, we
  751. assign -1 to each of the parameters type and from.  This is done
  752. because -1 represents a wildcard value indicating we are willing to
  753. receive a message of any type from any process.  Here, we could have
  754. coded type to be 100, and specified from equal to the value of i each
  755. time through the loop (skipping our own id).  By setting incoming to
  756. NULL, we have also indicated to `p4_recv' that we do not have a
  757. buffer in which to place the received message, so `p4_recv' should
  758. obtain a buffer for us and place the message in that buffer.
  759. `p4_recv' treats these three parameters as both input and output
  760. values.  Thus, it alters the value of each such that type and from
  761. indicate the type of message received and the id of the process that
  762. sent it.  The value of `incoming' is altered to point to the
  763. buffer where the message was placed.  The `size parameter' is
  764. strictly an output parameter and iindicates the size of the received
  765. message.  It is possible for the user to provide his own buffer; this
  766. will be demonstrated later.
  767.  
  768.  
  769. Finally, note that `p4_msg_free' frees the message buffer obtained by
  770. `p4_recv.' The procedure `p4_msg_free' should be called only after
  771. the contents of the message are no longer needed.  `P4_msg_free' should
  772. be used to free these buffers because, although a user only sees the data
  773. portion of a message, p4 internally represents a message as a structured data
  774. item.
  775.  
  776. To compile and link this program for execution, you need to create a
  777. makefile.  We will assume that you have installed p4 in
  778. `/usr/local/p4' and that you have typed the program above into a
  779. file name `p4simple.c' in the directory
  780. `/home/mylogin/p4pgms'.
  781.  
  782. To build your makefile, copy the file
  783.          /usr/local/p4/messages/makefile.proto
  784.  
  785. into your working directory.  This is a prototype makefile that
  786. contains machine-independent information, and which p4 can use to build a
  787. machine-specific makefile for your program.  This prototype makefile contains
  788. information about several sample programs that demonstrate
  789. message-passing in p4.  If you edit this file, you will see information
  790. for making a program named `sr_test'.  Do a global change of
  791. `sr_test' to `p4simple'.  You should also change the value of
  792. `P4_HOME_DIR'.  It should contain the full
  793. pathname of the p4 system, e.g. `/usr/local/p4'.  Now change
  794. directories to `/usr/local/p4' and type:
  795.  
  796.      make makefiles MACHINE=<machine_type> DIRS=/home/mylogin/p4pgms
  797.  
  798. where `<your_machine_type>' is the machine type that you specified when
  799. you installed p4 on your machine.  Now, you should be able to change
  800. back to your directory and see a file named Makefile there.  
  801. You should then be able to type:
  802.  
  803.          make p4simple
  804.  
  805.  
  806. There is one last piece missing before you can execute your program.
  807. Recall that `p4_create_procgroup' needs to know how many processes
  808. to start and where to start them; it reads a file (called a
  809. "procgroup file") to gather this information.  p4 always assumes
  810. that you have a master process, and that you describe the slave
  811. processes (process groups) in the procgroup file.  You can name a
  812. procgroup file any name you choose, but `procgroup' is the default
  813. name.  The information contained in procgroup files can get fairly
  814. involved, but if you have a computer that supports shared memory among
  815. processes, then you can code a very simple example at first.
  816.  
  817. Let us suppose first that you want to run your program on a network of
  818. workstations.  Then your procgroup should look something like:
  819.  
  820.          local O
  821.          some.network.machine 1 /home/me/p4progs/p4simple
  822.  
  823.  
  824. This file indicates that you wish to run only the master on the local machine
  825. (the one you are logged into when you execute the program) and one slave on
  826. the machine `some.network.machine'.
  827.  
  828. Now, all you have to do to run your program is type:
  829.  
  830.          p4simple
  831.  
  832.  
  833. You should see a line printed each time a process receives a message
  834. from another process (on some machines, there may be a restriction that
  835. only one process can do I/O, however such restrictions are not
  836. common).  Experiment by changing the number of slaves indicated in the
  837. procgroup file.
  838.  
  839. You may notice that even a small p4 program becomes large when linked
  840. with the p4 library.  You might consider using `strip' to reduce
  841. the size or removing `-g' from the CFLAGS in the makefile.
  842.  
  843. 
  844. File: p4.info  Node: Command-Line Arguments, Prev: Developing a Simple p4 Program, Up: Top, Next: The p4 Function Library
  845.  
  846.  
  847. Command-Line Arguments
  848. ======================
  849.  
  850.  
  851.  
  852. The command-line arguments to a p4 program are all optional.
  853.      -help           get this information and the version number, then exit
  854.      -pg             procgroup_file
  855.      -dbg            set debug level 
  856.      -rdbg           set remote debug level
  857.      -gm             set globmemsize
  858.      -dmn            provide local domainname
  859.      -outfile        output file for master
  860.      -routfile       output file prefix for remote masters
  861.      -ssport         port# private port number for secure server
  862.      -p4log          enable internal p4 logging by alog
  863.      -p4version      print the current p4 version number
  864.  
  865.  
  866.  
  867. 
  868. File: p4.info  Node: The p4 Function Library, Prev: Command-Line Arguments, Up: Top, Next: p4 Functions for Managing Processes and Clusters
  869.  
  870.  
  871. The p4 Function Library
  872. =======================
  873.  
  874.  
  875. * Menu:
  876.  
  877. * Overview of the Library::
  878. * Return Codes from p4 Functions::
  879.  
  880.  
  881. 
  882. File: p4.info  Node: Overview of the Library, Prev:     , Up: The p4 Function Library, Next: Return Codes from p4 Functions
  883.  
  884.  
  885. Overview of the Library
  886. -----------------------
  887.  
  888.  
  889. In the following sections, we provide details for each p4 function in the
  890. library.  The procedures are gathered into the following groups:
  891.  
  892.    * Functions for managing processes and clusters
  893.    * Functions for message passing
  894.    * Functions for shared memory
  895.    * Functions for timing p4 programs
  896.    * Functions for debugging p4 programs
  897.    * Miscellaneous functions
  898.    * Fortran interface functions
  899.  
  900.  
  901. 
  902. File: p4.info  Node: Return Codes from p4 Functions, Prev: Overview of the Library, Up: The p4 Function Library, Next:     
  903.  
  904.  
  905. Return Codes from p4 Functions
  906. ------------------------------
  907.  
  908.  
  909.  
  910. Most p4 functions return -1 if an error occurs.  Some, however, call the
  911. function `p4_error' when severe errors occur.  This function prints a
  912. message and then attempts to terminate all of the user's processes
  913. *Note Functions for Debugging p4 Programs::.
  914.  
  915. 
  916. File: p4.info  Node: p4 Functions for Managing Processes and Clusters, Prev: The p4 Function Library, Up: Top, Next: Functions for Message Passing
  917.  
  918.  
  919. p4 Functions for Managing Processes and Clusters
  920. ================================================
  921.  
  922.  
  923. In some situations a p4 procedure will give an error message and then
  924. exit.  This is typically done as a result of a failed system call and
  925. handled by calling the p4 procedure named `p4_error' that examines the
  926. return values from socket procedures, etc.  Most of the time however,
  927. the procedures simply return a value.  Some of the procedures return no
  928. value and thus are declared to return `VOID'.  Some of the
  929. procedures return either a pointer to a character string or `NULL';
  930. `NULL' indicates an error.  The remaining procedures return an
  931. integer value; (-1) indicates an error.
  932.  
  933.  
  934. * Menu:
  935.  
  936. * Functions for Process Management::
  937. * Functions for Cluster Management::
  938.  
  939.  
  940. 
  941. File: p4.info  Node: Functions for Process Management, Prev:     , Up: p4 Functions for Managing Processes and Clusters, Next: Functions for Cluster Management
  942.  
  943.  
  944. Functions for Process Management
  945. --------------------------------
  946.  
  947.  
  948.  
  949. In this section we describe the p4 functions needed for basic creation and
  950. termination of processes.
  951.  
  952.  
  953.      int p4_initenv(argc,argv)
  954.      int *argc;
  955.      char **argv;
  956.  
  957. should be called by your program before an attempt is made to use
  958. any p4 procedures or data areas.  We suggest making it the first executable
  959. statement in your program.  `p4_initenv' parses the command line
  960. arguments and extracts the ones intended for p4 ignoring all others (see the
  961. discussion of command line arguments).  Note that you pass the address of
  962. `argc' to `p4_initenv' so that it can actually remove its own
  963. arguments before your program looks at them.
  964.  
  965.  
  966.      int p4_create(fxn)
  967.      int (*fxn)();
  968.      
  969.      
  970.      int p4_create_procgroup()
  971.  
  972. There are two procedures that you can use to create processes in p4,
  973. `p4_create_procgroup' and `p4_create'.  Processes created via
  974. `p4_create' are said to be "user-managed" whereas those created
  975. by `p4_create_procgroup' are "p4-managed".  The p4-managed
  976. processes are automatically assigned unique id's (beginning with 0 for
  977. the big master), they have message queues allocated for them so that
  978. they can do message-passing, and they are able to run either on a
  979. shared-memory multiprocessor with the creating process or they can run
  980. on a separate machine.  Processes created via `p4_create' do not
  981. have any of these advantages.  They must develop their own id's, they
  982. cannot do message-passing, and they can only run on a shared-memory
  983. multiprocessor with the creating process.  The only disadvantage of
  984. `p4_create_procgroup' is that you must build a `procgroup'
  985. file describing the set of required slave processes before the master
  986. program begins execution.  This eliminates the possibility of
  987. determining late in the execution exactly how many processes you want
  988. to use to solve a problem.  Generally, this is not a problem,
  989. especially since we can combine `p4_create_procgroup' and
  990. `p4_create' in the following way: You can use
  991. `p4_create_procgroup' to develop a network of processes that talk
  992. to each other via messages.  Each of those processes can create further
  993. processes to help it out as necessary.  The original set of processes
  994. communicate with their local slaves through shared data areas and with
  995. each other via message-passing.
  996.  
  997. `p4_create' receives one argument that is a pointer to a function.  It
  998. creates a single new process that executes the indicated function.  The
  999. new process may share data areas (in shared memory) with the parent
  1000. process.  However, the new process is not managed by the p4 system in
  1001. the sense that it is not assigned an id, it cannot pass messages, etc.
  1002. The only p4 procedure that deals with user-managed slaves is `p4_create'.
  1003. No other procedures are even aware of their existence.
  1004.  
  1005. `p4_create_procgroup' reads your `procgroup' file to determine the 
  1006. number of slave processes to create and where they are to be placed.  It
  1007. builds a procgroup table that describes all created processes and gives
  1008. a copy of the table to each process.  The processes then use the table
  1009. to discover how to communicate with each other (processes in a cluster
  1010. can send messages directly through shared memory or some other
  1011. vendor-specific mechanism), others communicate via sockets). 
  1012. An alternative method is to build the table in memory yourself and use
  1013. `p4_startup'.
  1014.  
  1015. The effect of `p4_create_procgroup' can be obtained in another way if a
  1016. system would prefer to use its own way of specifying the locations of
  1017. processes.  A user may allocate the procgroup data structure and then fill it
  1018. in "by hand" rather than by reading a file in p4 procgroup format.  The
  1019. following procedures support this method of starting processes.
  1020.  
  1021.  
  1022.      struct p4_procgroup *p4_alloc_procgroup()
  1023.  
  1024. allocates a procgroup data structure of the form described in `p4.h'.
  1025. The formats of individual entries (`p4_procgroup_entry') are given there
  1026. as well. 
  1027.  
  1028.  
  1029.      int 4_startup(pg)
  1030.      struct p4_procgroup *pg;
  1031.  
  1032. starts processes as specified by an an already-created procgroup data
  1033. structure allocated by `p4_alloc_procgroup' and filled in by the user
  1034. using the structures `p4_procgroup_entry' and `p4_procgroup'.
  1035.  
  1036.  
  1037.  
  1038.      VOID p4_wait_for_end()
  1039.  
  1040. is the p4 termination/cleanup procedure that you should invoke at the
  1041. end of every execution of a program that uses p4.  
  1042. It does some termination processing and then waits for slave processes 
  1043. to end.
  1044.  
  1045.  
  1046.      int p4_get_my_id()
  1047.  
  1048. returns an integer value representing the id of the process assigned by
  1049. the p4 system.  If the process is not a p4-managed process, the value
  1050. (-1) is returned.
  1051.  
  1052.  
  1053.      int p4_num_total_ids()
  1054.  
  1055. returns an integer value indicating the total number of ids started
  1056. by p4 in all clusters, including the big master and all remote masters.
  1057.  
  1058.  
  1059.      int p4_num_total_slaves()
  1060.  
  1061. returns an integer value indicating the total number of processes started
  1062. by p4 in all clusters, including all remote masters but not the big master.
  1063.  
  1064. 
  1065. File: p4.info  Node: Functions for Cluster Management, Prev: Functions for Process Management, Up: p4 Functions for Managing Processes and Clusters, Next:     
  1066.  
  1067.  
  1068. Functions for Cluster Management
  1069. --------------------------------
  1070.  
  1071.  
  1072.  
  1073. The p4 system supports the "cluster" model of parallel computation, in
  1074. which subsets of processes share memory with one another, with the clusters
  1075. communicating via messages.  A procgroup file for a program written for the
  1076. cluster model might look like this:
  1077.  
  1078.          local 4
  1079.          alliant1.abc.edu     5 /home/me/myprog
  1080.          alliant2.abc.edu     5 /home/me/myprog
  1081.          encore.somewhere.edu 5 /usrs/me/myprog
  1082.  
  1083.  
  1084. This would specify a total of 20 processes, 5 (including the master) running
  1085. on the local machine (here assumed to be capable of supporting five processes
  1086. that share memory) together with 5 slaves each on three other shared-memory
  1087. machines.
  1088.  
  1089.  
  1090.      VOID p4_get_cluster_ids(start,end)     
  1091.      int *start;
  1092.      int *end;
  1093.  
  1094. receives pointers to two integers.  It places the p4-assigned id's of
  1095. the first and last ids within the current cluster into the two
  1096. arguments (including the remote master).
  1097.  
  1098.  
  1099.      int p4_get_my_cluster_id()
  1100.  
  1101. returns a unique id (relative to 0) within a cluster of p4-managed
  1102. processes.  Thus, a cluster master will always have a cluster id of 0.
  1103. It is not clear that a separate cluster id is really useful, but the
  1104. functionality is provided just in case.
  1105.  
  1106.  
  1107.      BOOL p4_am_i_cluster_master()
  1108.  
  1109. returns a BOOL value indicating whether the invoking process is the
  1110. "cluster master" process within its cluster.
  1111.  
  1112.  
  1113.      int p4_num_cluster_ids()
  1114.  
  1115. returns an integer value indicating the number of ids in the current
  1116. cluster as started by `p4_create_procgroup'.  
  1117.  
  1118.  
  1119. 
  1120. File: p4.info  Node: Functions for Message Passing, Prev: p4 Functions for Managing Processes and Clusters, Up: Top, Next: Functions for Shared Memory
  1121.  
  1122.  
  1123. Functions for Message Passing
  1124. =============================
  1125.  
  1126.  
  1127.  
  1128. P4 supports a set of send/receive procedures.  These procedures are
  1129. "generic" in the sense that they do not know whether a message must
  1130. travel across a network or through shared memory, or via some other
  1131. mechanism.  They depend on a lower-level set of procedures that handle
  1132. local or network (remote) communications.  By default, the messages
  1133. are assumed to be typed.  If the user wishes to use untyped messages,
  1134. he can hide the typing by coding some very simple C macros that always
  1135. use a single message type.
  1136.  
  1137.  
  1138. * Menu:
  1139.  
  1140. * Explicit Sending and Receiving of Messages::
  1141. * Global Operations::   
  1142.  
  1143.  
  1144. 
  1145. File: p4.info  Node: Explicit Sending and Receiving of Messages, Prev:     , Up: Functions for Message Passing, Next: Global Operations
  1146.  
  1147.  
  1148. Explicit Sending and Receiving of Messages
  1149. ------------------------------------------
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.      p4_send(type,to,msg,len)
  1162.      p4_sendr(type,to,msg,len)
  1163.      p4_sendx(type,to,msg,len,datatype)
  1164.      p4_sendrx(type,to,msg,len,datatype)
  1165.      p4_sendb(type,to,msg,len)
  1166.      p4_sendbr(type,to,msg,len)
  1167.      p4_sendbx(type,to,msg,len,datatype)
  1168.      p4_sendbrx(type,to,msg,len,datatype)
  1169.      
  1170.      int type, to, len, datatype;
  1171.      char *msg;
  1172.  
  1173.  
  1174. Each of these procedures sends a message.  The `type' argument is
  1175. an integer value chosen by the user to represent a message type.  The
  1176. `to' argument is an integer value that specifies the p4-id of the
  1177. process that should receive the message.  The `len' argument
  1178. contains the length of the message to be passed.  Note that some of the
  1179. procedures have a "b" in their name, e.g.  `p4_sendb'.  These
  1180. procedures assume that the msg is in a buffer that the user obtained
  1181. earlier via a `p4_msg_alloc'; otherwise, the buffer is assumed to
  1182. be in the user's local space, and may cause the message to be copied
  1183. internally.  The procedures with an "r" in the name do not return
  1184. until an acknowledgement is received from the `to' process (the
  1185. "r" stands for rendezvous).  Those procedures with an "x" in the
  1186. name take an extra argument (datatype) that specifies the type of data
  1187. in the message; these procedures will use that information to call XDR
  1188. for data conversion if the message is being passed to a machine of a
  1189. different architecture, i.e. where the internal representation may be
  1190. different.
  1191.  
  1192.  
  1193.  
  1194.      BOOL p4_messages_available(req_type,req_from)
  1195.      int *req_type,*req_from;
  1196.  
  1197. returns a BOOL value indicating whether the process has any messages available
  1198. or not.  The parameters `req_type' and `req_from' are both pointers
  1199. to integers; they are used as {both} input and arguments.  On input,
  1200. `req_type' has a value that indicates the type of message that the user
  1201. wishes to check for availability (-1 indicates any type).  The variable
  1202. `req_from' is used similarly to indicate who a message is desired from.
  1203.  
  1204.  
  1205.  
  1206.      int p4_recv(req_type,req_from,msg,len_rcvd)
  1207.      int *req_type,*req_from,*len_rcvd;
  1208.      char **msg;
  1209.  
  1210. pointer to a `char'.  If this value is NULL, then p4 will allocate the
  1211. buffer for the message according to its length.  That is, one need not know
  1212. ahead of time the length of a message being received.  If this value is not
  1213. NULL, then it points to a p4 message buffer that the user has obtained via
  1214. `p4_msg_alloc'.  The `len_rcvd' argument is a pointer to an integer
  1215. that is assigned the length of the received message.  `Req_type' and
  1216. `req_from' are both pointers to integers; they are used as both input and
  1217. arguments.  On input, `req_type' has a value that indicates the type of
  1218. message that the user wishes to receive (-1 indicates any type).  It will
  1219. block until a message of that type is available.  `Req_from' is used
  1220. similarly to indicate who a message is desired from.  One important note about
  1221. this procedure is that it obtains the area in which to place a message, and
  1222. the user must explicitly free that area when finished with it (see
  1223. `p4_msg_free').  There is an option available with `p4_recv' in
  1224. which the user can provide his own buffer rather than having p4 allocate it.
  1225. To do this, the user points `msg' to a buffer that he must obtain via a
  1226. call to `p4_msg_alloc' (see below).  Then he assigns `len_rcvd' a
  1227. value which is the length of that buffer.  In this case, `len_rcvd' is
  1228. both an input and output variable.  In addition, no `p4_msg_free' need be
  1229. performed if the same buffer is going to be re-used multiple times.
  1230.  
  1231.  
  1232.  
  1233.      char *p4_msg_alloc(len)
  1234.      int len;
  1235.  
  1236. obtains a pointer to a buffer area that can be used to receive a 
  1237. message.  This procedure should be used for this task because a 
  1238. message has hidden information which the user is unaware of and 
  1239. therefore should not use malloc to obatin the area.
  1240.  
  1241.  
  1242.  
  1243.      VOID p4_msg_free(m)
  1244.      char *m;
  1245.  
  1246. frees the message pointed to by `m.'  This procedure should be used
  1247. for this task because a message has hidden information which the
  1248. user is unaware of and therefore cannot be freed by the user.
  1249.  
  1250.  
  1251. 
  1252. File: p4.info  Node: Global Operations, Prev: Explicit Sending and Receiving of Messages, Up: Functions for Message Passing, Next:     
  1253.  
  1254.  
  1255. Global Operations
  1256. -----------------
  1257.  
  1258.  
  1259.  
  1260. P4 supports a number of operations for dealing with all processes at once.
  1261.  
  1262.  
  1263.      p4_broadcastx(type, data, data_len, data_type)
  1264.      int type;
  1265.      char *data;
  1266.      int data_len, data_type;
  1267.  
  1268.  
  1269.  
  1270.      p4_broadcast(type, data, data_len)
  1271.      int type;
  1272.      char *data;
  1273.      int data_len;
  1274.  
  1275. provide the ability to broadcast messages like `p4_send' and
  1276. `p4_sendx'.
  1277.  
  1278.  
  1279.      p4_global_op(type,x,nelem,size,op,data_type) 
  1280.      int type;
  1281.      char *x;
  1282.      int size, nelem;
  1283.      int (*op)();
  1284.      int data_type;
  1285.  
  1286. where `op' is one of:
  1287.      p4_int_absmax_op()
  1288.      p4_int_absmin_op()
  1289.      p4_int_max_op()
  1290.      p4_int_min_op()
  1291.      p4_int_mult_op()
  1292.      p4_int_sum_op()
  1293.      p4_dbl_absmax_op()
  1294.      p4_dbl_absmin_op()
  1295.      p4_dbl_max_op()
  1296.      p4_dbl_min_op()
  1297.      p4_dbl_mult_op()
  1298.      p4_dbl_sum_op()
  1299.      p4_flt_absmax_op()
  1300.      p4_flt_absmin_op()
  1301.      p4_flt_max_op()
  1302.      p4_flt_min_op()
  1303.      p4_flt_mult_op()
  1304.      p4_flt_sum_op()
  1305.  
  1306.  
  1307. and `data_type' is one of `P4INT', `P4LNG', `P4FLT', or
  1308. `P4DBL'.
  1309.  
  1310. This collection of routines provide the ability to do a variety of
  1311. global operations.  See the example programs in subdirectory
  1312. `p4/contrib'.  They apply the commutative operation `op' globally 
  1313. to `x' on an element-by-element basis and broadcast the result to 
  1314. all nodes.  That is each process ends up with
  1315.  
  1316.         for (i=0; i<n; i++)
  1317.               x[i] = x[node 0][i] op x[node 1][i] op x[node 2][i] op ...
  1318.  
  1319. `op' should be of the form
  1320.  
  1321.           VOID op(char *x, char *y, int nelem)
  1322.           {
  1323.               data_type *a = (data_type *) x;
  1324.               data_type *b = (data_type *) y;
  1325.      
  1326.               while (nelem--)
  1327.                   *a++ operation= *b++;
  1328.           }
  1329.  
  1330. where `data_type' and `operation' are chosen appropriately.
  1331.  
  1332. The order in which nodes apply the operation is undefined (hence
  1333. `op' must be commutative). The communication may be internally
  1334. sub-blocked so the function `op' should not be hardwired to specific
  1335. vector lengths.
  1336.  
  1337. This is still a relatively primitive version, which gathers the necessary data
  1338. up a balanced binary tree and then uses `p4_broadcast' to send the
  1339. results back. 
  1340.  
  1341.  
  1342.  
  1343.      VOID p4_global_barrier(type)
  1344.      int type;
  1345.  
  1346. This procedure takes one argument which is the message type to be 
  1347. used for internal message-passing.  It causes the invoking process to
  1348. hang until all processes specified in the procgroup file have invoked 
  1349. the procedure.
  1350.  
  1351.  
  1352. 
  1353. File: p4.info  Node: Functions for Shared Memory, Prev: Functions for Message Passing, Up: Top, Next: Functions for Timing p4 Programs
  1354.  
  1355.  
  1356. Functions for Shared Memory
  1357. ===========================
  1358.  
  1359.  
  1360.  
  1361.  
  1362. * Menu:
  1363.  
  1364. * Managing Shared and Local Memory::
  1365. * Shared Memory Data Types::
  1366. * Monitor-Building Primitives::
  1367. * Some Useful Monitors::
  1368.  
  1369.  
  1370. 
  1371. File: p4.info  Node: Managing Shared and Local Memory, Prev:     , Up: Functions for Shared Memory, Next: Shared Memory Data Types
  1372.  
  1373.  
  1374. Managing Shared and Local Memory
  1375. --------------------------------
  1376.  
  1377.  
  1378.  
  1379.      char *p4_malloc(n)
  1380.      int n;
  1381.  
  1382. typically acts like the standard `malloc', but may be rewritten for user 
  1383. systems that require different operation.
  1384.  
  1385.  
  1386.      VOID p4_free(p)
  1387.      char *p;
  1388.  
  1389. typically acts like the standard `free', but may be rewritten for
  1390. user systems that require different operation.
  1391.  
  1392.  
  1393.      char *p4_shmalloc()
  1394.  
  1395. acts like the standard `malloc' except will obtain shared memory on
  1396. machines that support sharing memory among processes.  Compare with
  1397. `p4_malloc'.
  1398.  
  1399.  
  1400.      VOID p4_shfree()
  1401.  
  1402. frees memory obtained with `p4_shmalloc'.  Compare with `p4_free'.
  1403.  
  1404.  
  1405. 
  1406. File: p4.info  Node: Shared Memory Data Types, Prev: Managing Shared and Local Memory, Up: Functions for Shared Memory, Next: Monitor-Building Primitives
  1407.  
  1408.  
  1409. Shared Memory Data Types
  1410. ------------------------
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416. The abstraction provided by p4 for managing data in shared memory is
  1417. "monitors".  Good places to learn about the monitor concept in general are
  1418. [pbh:architecture] and [hoare:monitors].  The specific approach
  1419. taken by p4 is described in [lusk-overbeek:p4-book].  P4 provides several
  1420. useful monitors (`p4_barrier_t', `p4_getsub_monitor_t',
  1421. `p4_askfor_monitor_t') as well as a general monitor type to help the user
  1422. in constructing his own monitors (`p4_monitor_t').
  1423.  
  1424. 
  1425. File: p4.info  Node: Monitor-Building Primitives, Prev: Shared Memory Data Types, Up: Functions for Shared Memory, Next: Some Useful Monitors
  1426.  
  1427.  
  1428. Monitor-Building Primitives
  1429. ---------------------------
  1430.  
  1431.  
  1432.  
  1433. The following functions can be used to construct monitors.  A monitor so
  1434. constructed has the type `p4_monitor_t'.
  1435.  
  1436.  
  1437.      int p4_moninit(m,i)
  1438.      p4_monitor_t *m;
  1439.      int i;
  1440.  
  1441. initializes the monitor pointed to by `m' and gives it `i' queues for
  1442. processes to wait on while they are blocked (see `delay').  One queue is
  1443. sufficient for most purposes.  The queues are numbered beginning with 0.
  1444.  
  1445.  
  1446.      VOID p4_menter(m)
  1447.      p4_monitor_t *m;
  1448.  
  1449. enter the monitor pointed to by m.  By the definition of a monitor,
  1450. access is restricted to a single process in the monitor at a time (if
  1451. everybody plays by the rules).
  1452.  
  1453.  
  1454.      VOID p4_mexit(m)
  1455.      p4_monitor_t *m;
  1456.  
  1457. exits the monitor pointed to by m.  You are of course assumed to have
  1458. previously entered that monitor.
  1459.  
  1460.  
  1461.      VOID p4_mcontinue(m,i)
  1462.      p4_monitor_t *m;
  1463.      int i;
  1464.  
  1465. checks to see if there are any processes blocked on the `i'-th queue of
  1466. the monitor `m' and causes one of them to be released for entry to the
  1467. monitor if so.  If there are no such processes, the invoking process
  1468. simply exits.  Note that a process could have been blocked previously
  1469. by invoking the procedure `p4_mdelay'.  The queues are numbered 
  1470. beginning with 0.
  1471.  
  1472.  
  1473.      VOID p4_mdelay(m,i)
  1474.      p4_monitor_t *m;
  1475.      int i;
  1476.  
  1477. permits a process to delay itself on the `i'-th queue of monitor
  1478. `m' if the process wishes to release the monitor, but wants to be
  1479. waked up by another process later (via the procedure `p4_mcontinue').
  1480. The queues are numbered beginning with 0.
  1481.  
  1482.  
  1483. 
  1484. File: p4.info  Node: Some Useful Monitors, Prev: Monitor-Building Primitives, Up: Functions for Shared Memory, Next:     
  1485.  
  1486.  
  1487. Some Useful Monitors
  1488. --------------------
  1489.  
  1490.  
  1491.  
  1492. In this section we describe some of the specific monitors that are built into
  1493. the p4 library.  Each of them has its own pre-defined type, which can be
  1494. used to allocate storage for them, which should be in shared memory.
  1495. See the `p4/monitors' directory for examples.  A lock is itself a
  1496. monitor, with no extra delay queues.
  1497.  
  1498.  
  1499.      VOID p4_lock_init(l)
  1500.      p4_lock_t *l;
  1501.  
  1502. initializes the lock `l'.  Must be used prior to any attempts to lock or
  1503. unlock `l'.
  1504.  
  1505.  
  1506.  
  1507.      VOID p4_lock(l)
  1508.      p4_lock_t *l;
  1509.  
  1510. blocks if the lock `l' is already locked, otherwise locks `l'
  1511. and proceeds.
  1512.  
  1513.  
  1514.  
  1515.      VOID p4_unlock(l)
  1516.      p4_lock_t *l;
  1517.  
  1518. unlocks the lock `l'.
  1519.  
  1520.  
  1521.      VOID p4_getsub(gs,s,max,nprocs)
  1522.      p4_getsub_monitor_t *gs;
  1523.      int *s,max,nprocs;
  1524.  
  1525. is a procedure used to obtain the next value of a shared counter
  1526. (subscript).  It takes as its first argument, a pointer to a getsub
  1527. monitor that protects the shared counter.  It assigns the current value
  1528. of the counter to the integer that s points to, and then increments the
  1529. counter by 1.  `p4_getsub_init' initially sets the counter to 0.
  1530. When the counter passes the value `max', all `nprocs'
  1531. processes are returned the value (-1) once, then the counter is reset to
  1532. 0 for further use.
  1533.  
  1534.  
  1535.      VOID p4_getsubs(gs,s,max,nprocs,stride)
  1536.      p4_getsub_monitor_t *gs;
  1537.      int *s,max,nprocs,stride;
  1538.  
  1539. is like `p4_getsub' except that the counter is increased on each call by
  1540. `stride' instead of 1.
  1541.  
  1542.  
  1543.  
  1544.      int p4_getsub_init(gs)
  1545.      p4_getsub_monitor_t *gs;
  1546.  
  1547. initializes the getsub monitor pointed to by `gs'; this initialization
  1548. includes assigning a value of 0 to the counter that the monitor
  1549. protects.
  1550.  
  1551.  
  1552. The standard barrier synchronization pattern is expressed as a monitor.
  1553. There can be multiple barrier monitors, and one can wait for only some
  1554. of the processes at the barrier if this is desired.
  1555.  
  1556.  
  1557.  
  1558.      VOID p4_barrier(b,nprocs)
  1559.      p4_barrier_monitor_t *b;
  1560.      int nprocs;
  1561.  
  1562. causes the executing process to hang until `nprocs' processes execute
  1563. a barrier instruction with a pointer to the same barrier monitor `b'
  1564. as an argument.
  1565.  
  1566.  
  1567.      int p4_barrier_init(b)
  1568.      p4_barrier_monitor_t *b;
  1569.  
  1570. initializes the barrier monitor `b'; this procedure should be invoked
  1571. before you attempt to use the monitor in any operations.
  1572.  
  1573. Finally, the `askfor' monitor functions like a general dispatcher of
  1574. work. 
  1575.  
  1576.  
  1577.  
  1578.      int p4_askfor(af,nprocs,getprob_fxn,problem,reset_fxn)
  1579.      p4_askfor_monitor_t *af;
  1580.      int nprocs;
  1581.      int (*getprob_fxn)();
  1582.      VOID *problem;
  1583.      int (*reset_fxn)();
  1584.  
  1585. requests a new "problem" to work on from the problem pool.  The
  1586. arguments are (1) a pointer to the askfor monitor that protects the
  1587. problem pool, (2) the number of processes that call this procedure
  1588. (with `af') looking for work, (3) a pointer to the user-written procedure
  1589. that obtains a problem from the pool, (4) a pointer that is filled in
  1590. with the address of a user-defined representation of a problem to be
  1591. solved, and (5) a pointer to a user-written procedure to reset when all
  1592. problems in the pool are solved, in case the same monitor is re-used
  1593. for another set of problems later.  `p4_askfor' returns an integer
  1594. indicating whether a problem was successfully obtained or not:
  1595.  
  1596.          -1     : program is terminating (some process called p4_progend)
  1597.           0     : a problem was obtained and "problem" points to it
  1598.           1     : problem solved by exhaustion, i.e. no more problems to get
  1599.           n > 1 : a process found a solution and called p4_probend with code n
  1600.  
  1601. For a detailed discussion of the "askfor" monitor, see
  1602. [lusk-overbeek:p4-book].
  1603.  
  1604.  
  1605.      int p4_update(af,putprob_fxn,problem)
  1606.      p4_askfor_monitor_t *af;
  1607.      int (*putprob_fxn)();
  1608.      VOID *problem;
  1609.  
  1610. updates the problem pool being managed by the askfor monitor.  The
  1611. arguments are (1) a pointer to the askfor monitor that protects the
  1612. problem pool, (2) a pointer to the user-written procedure that puts
  1613. problems into the pool, and (3) a pointer to a user-defined
  1614. representation of a problem to be put in the pool.  `Putprob_fxn'
  1615. should return 1 if it did indeed put a new problem into the pool, so
  1616. that any delayed processes should wake up and re-examine the pool (this
  1617. logic is handled by the `p4_askfor') and 0 if upon entering the
  1618. monitor and examining its potential problem together with the data there
  1619. it decided not to add a new problem to the pool.  It can be assumed that
  1620. the "putprob" logic (defined by `putprob_fxn') is executed inside
  1621. the monitor.
  1622.  
  1623.  
  1624.      int p4_askfor_init(af)
  1625.      p4_askfor_monitor_t *af;
  1626.  
  1627. initializes the askfor monitor `af'; this procedure should be invoked
  1628. before you attempt to use the monitor in any operations.
  1629.  
  1630.  
  1631.      VOID p4_probend(af,code)
  1632.      p4_askfor_monitor_t *af;
  1633.      int code;
  1634.  
  1635. allows the user process to mark a problem as solved early when
  1636. several processes are coordinating their activities via an askfor
  1637. monitor.  The code is an integer value that will be returned to all
  1638. processes when they "askfor" a new sub-problem to work on.
  1639.  
  1640.  
  1641.      VOID p4_progend(af)
  1642.      p4_askfor_monitor_t *af;
  1643.  
  1644. allows a process to cause a return code of (-1) to be returned to all
  1645. processes using an askfor monitor.  This would typically be called by
  1646. a master process to indicate that no more problems are to be solved
  1647. and that all slave processes should terminate.
  1648.  
  1649.  
  1650. 
  1651. File: p4.info  Node: Functions for Timing p4 Programs, Prev: Functions for Shared Memory, Up: Top, Next: Functions for Debugging p4 Programs
  1652.  
  1653.  
  1654. Functions for Timing p4 Programs
  1655. ================================
  1656.  
  1657.  
  1658.  
  1659. A small number of simple functions are available for accessing various
  1660. clocks and timers.  
  1661.  
  1662.  
  1663.      int p4_clock()
  1664.  
  1665. returns a value in milliseconds.  This is a wall-clock value, usually obtained
  1666. from the system via `gettimeofday'.  Also see `p4_ustimer' below.
  1667.  
  1668.  
  1669.      p4_usc_time_t p4_ustimer()
  1670.  
  1671. returns a wall-clock time value in microseconds.  The precision of this
  1672. number depends on the timer installed on the individual machine.  In
  1673. some cases the resolution may be no greater than that of `p4_clock()'.
  1674. For arithmetic and printing purposes, the type `p4_usc_time_t' is an
  1675. unsigned long integer.
  1676.  
  1677.  
  1678.      p4_usc_time_t p4_usrollover()
  1679.  
  1680. returns the timer value at which a microsecond timer "rolls over".
  1681. Since `p4_usc_time_t' is a long integer's worth of microseconds, it is
  1682. likely that the timer will roll over (become zero) during even
  1683. medium-length runs.
  1684.  
  1685.  
  1686. 
  1687. File: p4.info  Node: Functions for Debugging p4 Programs, Prev: Functions for Timing p4 Programs, Up: Top, Next: Miscellaneous Functions
  1688.  
  1689.  
  1690. Functions for Debugging p4 Programs
  1691. ===================================
  1692.  
  1693.  
  1694.  
  1695. P4 has a set of routines to aid in producing a printed trace of events, both
  1696. user-defined and pre-defined in the p4 system.
  1697.  
  1698.  
  1699.      VOID p4_dprintf(fmt, va_alist)
  1700.      char *fmt;
  1701.      va_dcl
  1702.  
  1703. acts just like the standard `printf' except that the print line is
  1704. preceded by a value that identifies the process.  This value is
  1705. typically the string `pn_u' where `n' represents the
  1706. p4-assigned id and `u' represents the unix-id of the process on its
  1707. host.  However, there are other forms of this value.  For example, the
  1708. big master is represented as `bm_u'.  Also, if a process prints
  1709. before it has a p4-assigned id, then its value will be something like
  1710. `bm_slave_n_u' or `rm_slave_n_u'.  Typically, it is not
  1711. possible for a user program to print anything before being assigned an
  1712. id by p4, but the p4 system itself may use this procedure to print
  1713. messages from a particular process if it encounters problems getting the
  1714. process initialized.
  1715.  
  1716.  
  1717.      VOID p4_dprintfl(level, fmt, va_alist)
  1718.      int level;
  1719.      char *fmt;
  1720.      va_dcl
  1721.  
  1722. is like `p4_dprintf' except that the first argument is an integer
  1723. indicating the debugging level that must be in effect before this
  1724. message will print.  A level of 0 will cause the message to always print.
  1725. If you run a program with the debug level set to 5 (via command-line
  1726. arguments), then all `dprintfl''s with level less than or equal to
  1727. that debug level will print. *Note Command-Line Arguments:: for how to
  1728. set the debug level at run time.
  1729.  
  1730. The debug level can be examined and changed by the user during execution:
  1731.  
  1732.  
  1733.      int p4_get_dbg_level()     
  1734.  
  1735. returns the current debug level for this process and its cluster.
  1736.  
  1737.  
  1738.      VOID p4_set_dbg_level(level)     
  1739.      int level;
  1740.  
  1741. sets the current debug level for this process and its cluster.
  1742. P4 itself is liberally instrumented with `p4_dprintfl''s of level
  1743. 10 and above, leaving levels 0-9 for the user.  The greater the debug
  1744. level of the built-in messages, the greater understanding of p4 needed
  1745. by the user to make sense of them.  However, levels as high as 30 may
  1746. well be useful to the user trying to debug a p4 program.
  1747. Roughly speaking, the following debug levels produce messages about the
  1748. indicated events.
  1749.  
  1750.      level 10:  created process
  1751.                 sent message
  1752.                 received message
  1753.      
  1754.      level 20:  creating process
  1755.                 sending message
  1756.                 receiving message
  1757.                 process starting
  1758.                 process exiting
  1759.      
  1760.      level 30:  waiting for ack
  1761.                 sending ack
  1762.                 sent ack
  1763.                 received ack
  1764.                 queueing message for later receipt
  1765.                 queued message for later receipt
  1766.      
  1767.      level 40:  memory management
  1768.                 buffer management
  1769.      
  1770.      level 50:  reading procgroup
  1771.                 other initialization message exchange
  1772.      
  1773.      level 60:  send-receive details, especially machine-specific traces
  1774.      
  1775.      level 70:  listener interactions:
  1776.                  creating listener
  1777.                  created listener
  1778.                  messages from inside listener
  1779.      
  1780.      level 80:  detailed data structures after initialization
  1781.      
  1782.      level 90:  detailed tracing of flow thru procedures
  1783.  
  1784.  
  1785. For optimum performance, the test of the debug level required by these
  1786. messages can be removed at compile time by not commenting out the 
  1787. `#define P4_DPRINTFL' line in the `OPTIONS' file.
  1788. (*Note Structure of the Distribution Directory::).
  1789.  
  1790. The following function is provided to deal with abnormal termination.
  1791. It can be called by any process.
  1792.  
  1793.  
  1794.      VOID p4_error(string, value)
  1795.      char *string;
  1796.      int value;
  1797.  
  1798. prints `string' as an error message and then forcefully terminates
  1799. all co-operating processes and cleans up all shared resources.
  1800.  
  1801.  
  1802.      VOID p4_soft_errors(onoff)     
  1803.      int onoff;
  1804.  
  1805. enables/disables soft errors, returning the previous setting.  The default
  1806. is "disabled", which means that certain p4 functions will call
  1807. `p4_error' instead of returning -1.
  1808.  
  1809.  
  1810. `p4_error' gets control on certain kinds of interrupts.  It is
  1811. automatically called for `SIGSEGV', `SIGBUS', and `SIGFPE'
  1812. interrupts, to catch user programming errors and clean up, after which it
  1813. returns interrupt handling to default mode and returns, so that the user
  1814. may obtain a dump.  It also handles `SIGINT' interrupts, in which case
  1815. it cleans up and exits.  Finally, it may be called directly by the user, in
  1816. which case it cleans up (other p4 processes and IPC's) and exits.
  1817.  
  1818.  
  1819. Although `p4_error' is supposed to get rid of all running p4
  1820. processes, it can happen that an error is bad enough that p4 processes
  1821. are left running.  A primitive aid in finding and killing these
  1822. processes is the shell script `kj', which takes a string as an
  1823. argument and then kills processes containing that string as part of
  1824. their program names.  Currently it only kills processes on the machine
  1825. where it is run, but it can be run via `rsh' on remote machines.
  1826. There are other useful scripts (e.g. `killipc' and `killp4')
  1827. in the `p4/bin' directory to do such things as clean up SYSV IPC 
  1828. items that may be left when a program abnormally terminates.  P4 will 
  1829. generally cleanup these items if the abnormal termination is a type that 
  1830. p4 traps, otherwise the user must do the cleanup.  This is an unfortunate
  1831. side-effect of the way that SYSV handles things, it really should be
  1832. the OS's function to take care of this.
  1833.  
  1834. On many machines it is possible to attach a debugger like `dbx' to a
  1835. running process.  This is one way to find out where a hanging process is
  1836. stuck. 
  1837.  
  1838. 
  1839. File: p4.info  Node: Miscellaneous Functions, Prev: Functions for Debugging p4 Programs, Up: Top, Next: Fortran Interface
  1840.  
  1841.  
  1842. Miscellaneous Functions
  1843. =======================
  1844.  
  1845.  
  1846. In this section are found functions that do seem to fit neatly into any of the
  1847. other sections.
  1848.  
  1849.  
  1850.      char *p4_version()
  1851.  
  1852. returns a string containing the version number of p4 being run.
  1853.  
  1854.  
  1855.  
  1856.      VOID p4_get_cluster_masters(numids, ids)
  1857.      int *numids, ids[];
  1858.  
  1859. This procedure fills in the values of numids and ids.  It obtains the
  1860. p4-ids of all "cluster masters" for the program, placing them in the
  1861. ids array and placing the number of ids in numids.
  1862.  
  1863.  
  1864.      VOID p4_print_avail_buffs()
  1865.  
  1866. P4 maintains an array of buffer lists of various sizes, so that it can very
  1867. rapidly allocate and deallocate buffers.  You can see the contents of the
  1868. buffer pools at any time by calling this procedure.
  1869.  
  1870.  
  1871.  
  1872.      VOID p4_set_avail_buff(bufidx,size)
  1873.      int bufidx;
  1874.      int size;
  1875.  
  1876. This procedure is used to set the size of buffers in p4's buffer pools.  The
  1877. parameter `bufidx' specifies a particular buffer list, and should be a
  1878. number from 0 to 7.  The `size' parameter specifies that buffers up to
  1879. that size will be managed by p4 in a particular list.  It is important to
  1880. maintain the buffer sizes in increasing order.  The default list of buffer
  1881. sizes is {64, 256, 1024, 4096, 16384, 65536, 262144, 1048576}.  This causes
  1882. wasted space if you send only one large message, causing the allocation of a
  1883. large buffer which is not reused.  Savings in space can be achieved by
  1884. adjusting these numbers to correspond with the message sizes of your
  1885. application.  If no large messages are sent at all, however, no space is
  1886. wasted since the large buffers will never be allocated.  If you send a message
  1887. larger that the largest size in this array, p4 will allocate the buffer, and
  1888. then free it back to the system as soon as it can.
  1889.  
  1890.  
  1891. 
  1892. File: p4.info  Node: Fortran Interface, Prev: Miscellaneous Functions, Up: Top, Next: Faster Startup with the Secure Server
  1893.  
  1894.  
  1895. Fortran Interface
  1896. =================
  1897.  
  1898.  
  1899.  
  1900. The Fortran calls to p4 procedures are analogous to their C counterparts, but
  1901. have Fortran-like names.
  1902.  
  1903.      #include "p4f.h"
  1904.      
  1905.      p4init()
  1906.      p4crpg()
  1907.      p4cleanup()
  1908.      p4sendr(type,dest,msg,len,rc)
  1909.      p4sendrx(type,dest,msg,len,data_type,rc)
  1910.      p4send(type,dest,msg,len,rc)
  1911.      p4sendx(type,dest,msg,len,data_type,rc)
  1912.      p4recv(type,from,buf,buflen,msglen,rc)
  1913.      p4brdcst(type,data,len,rc)
  1914.      p4brdcstx(type,data,len,data_type,rc)
  1915.      p4probe(type,from,rc)
  1916.      p4myclid()
  1917.      p4nclids()
  1918.      p4getclids(start,end)
  1919.      p4myid()
  1920.      p4clock()
  1921.      p4ustimer()
  1922.      p4ntotids()
  1923.      p4error(str,val)
  1924.      p4softerrs(new,old)
  1925.      p4version()
  1926.      p4flush()
  1927.      p4globop(type,x,nelem,size,op,data_type,rc)
  1928.         p4intsumop()
  1929.         p4intabsmaxop()
  1930.         p4intabsminop()
  1931.         p4intmaxop()
  1932.         p4intminop()
  1933.         p4intmultop()
  1934.         p4dblsumop()
  1935.         p4dblabsmaxop()
  1936.         p4dblabsminop()
  1937.         p4dblmaxop()
  1938.         p4dblminop()
  1939.         p4dblmultop()
  1940.         p4fltsumop()
  1941.         p4fltabsmaxop()
  1942.         p4fltabsminop()
  1943.         p4fltmaxop()
  1944.         p4fltminop()
  1945.         p4fltmultop()
  1946.  
  1947.  
  1948. The `data_type' parameter in the above operations shoudl be one of
  1949. `P4INT', `P4LNG', `P4FLT', or `P4DBL'.
  1950. These symbolic constants are defined in the include file `p4f.h'.
  1951.  
  1952. 
  1953. File: p4.info  Node: Faster Startup with the Secure Server, Prev: Fortran Interface, Up: Top, Next: Utilities for Managing a p4 Session
  1954.  
  1955.  
  1956. Faster Startup with the Secure Server
  1957. =====================================
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964. P4 processes on remote machines are ordinarily created by `rsh'.
  1965. For this to work, the user must have permission to create processes on
  1966. that machine.  This permission is normally granted either globally by
  1967. the system administrator, or locally by the use of `.rhosts' files.
  1968. (See the normal unix man pages under `rhosts').
  1969.  
  1970. Since `rsh' is relatively slow, p4 provides a way to get things
  1971. started faster.  This is accomplished by running the program
  1972. `serv_p4' in the background on the remote machine.  When p4 is
  1973. creating processes, it will automatically check for the existence of
  1974. this server and use it if it is running.  Remote processes typically
  1975. start much faster when the server is running.  A disadvantage of using
  1976. the server is that output from `p4_dprintf' is lost unless directed
  1977. by a command-line argument to a file.  (*Note Command-Line Arguments::.)
  1978. When p4 uses `rsh', the remote process's `stdout' is sent
  1979. back to the `stdout' of the parent (the p4 master process).
  1980. We have not yet tested this server on all of the machines that we support.
  1981. Thus far, we have tested it somewhat on the SYMMETRY, SUN, DEC500, and
  1982. SGI.  We believe that it will work on many other machines, but have not
  1983. yet verified it on all machines.
  1984.  
  1985. An invocation of a set of servers is (currently) associated with a specific
  1986. port number.  This way multiple users can each be running multiple server
  1987. networks without mutual interference, provided each network of servers is
  1988. started with a different port number. 
  1989.  
  1990. To start the secrue server on a machine one can do
  1991.  
  1992.      serv_p4 -d -p <num>
  1993.  
  1994.  
  1995. where `<num>' is a port number to be associated with a network of
  1996. servers.  If the `-p' option is omitted, the server will pick an unused
  1997. port number and report
  1998.  
  1999.      Listening on <num>.
  2000.  
  2001.  
  2002. Then p4 programs to use this network should be started with 
  2003.  
  2004.      -ssport <num>
  2005.  
  2006.  
  2007. The p4 application must also be listed in the user's `.p4apps' file in
  2008. his home directory.  This file should be readable only by the user, and should
  2009. contain the full path names of programs that the user wishes to be startable
  2010. by the p4 server.
  2011.  
  2012. When a p4 master process tries to start a slave process on a remote machine,
  2013. it will first attempt to do it via the server.  If it cannot do so for any
  2014. reason (no server running, port number mismatch, or program not found in
  2015. `.p4apps' file), then it tries to do so with the remote shell command.
  2016.  
  2017. Note that the server is used only to start processes; it plays no role in a p4
  2018. computation once the slave processes have been initiated.  Rather, a temporary
  2019. process, called the {listener}, is spawned to manage connection requests
  2020. that occur during the execution of a p4 program.  Neither the server nor the
  2021. listener consumes any significant amount of CPU time.
  2022.  
  2023. There is further discussion of installation options for the servers in
  2024. the `README' file in the `p4/servers' subdirectory.
  2025.  
  2026. 
  2027. File: p4.info  Node: Utilities for Managing a p4 Session, Prev: Faster Startup with the Secure Server, Up: Top, Next: Creating Logfiles for Upshot
  2028.  
  2029.  
  2030. Utilities for Managing a p4 Session
  2031. ===================================
  2032.  
  2033.  
  2034.  
  2035.  
  2036. A number of useful utilities can be found in the `bin' subdirectory.
  2037. These can be used to start and stop server processes based on the contents of
  2038. a file of machines one regularly uses, to kill runaway p4 processes in the
  2039. unlikely case that they cannot or do not terminate automatically when one
  2040. processes ends abnormally or interrupted from the keyboard, and to merge
  2041. logfiles created for the use of `upshot' *Note Creating Logfiles for Upshot::. 
  2042.  
  2043. 
  2044. File: p4.info  Node: Creating Logfiles for Upshot, Prev: Utilities for Managing a p4 Session, Up: Top, Next: Machine-Specific Notes
  2045.  
  2046.  
  2047. Creating Logfiles for Upshot
  2048. ============================
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055. P4 is distributed with a set of routines for creating logfiles (see
  2056. `README' in the `p4/alog' directory.  The resulting logfiles
  2057. can be examined by `upshot', distributed separately.  For details
  2058. about `upshot', see [herrarte-lusk:upshot].  
  2059.  
  2060. The `p4/alog' directory contains a package (ALOG) for creating logs of
  2061. time-stamped events, that is of general utility, outside of p4.  The
  2062. timestamps are obtained from various microsecond-level resolution timers on
  2063. various machines.  The portable microsecond timing package is contained in the
  2064. `usc' subdirectory.  It is used by the ALOG package as well as by the
  2065. `p4_ustimer' function in p4.  Similarly, the ALOG package can be used
  2066. independently of p4 and `upshot'. Its logfiles were designed to be read
  2067. and displayed by upshot, but other display packages can be used as well.
  2068.  
  2069. * Menu:
  2070.  
  2071. * User-Specified Events::
  2072. * Examining Log Files with Upshot::
  2073. * Automatic Logging of p4 Events::
  2074.  
  2075.  
  2076. 
  2077. File: p4.info  Node: User-Specified Events, Prev:     , Up: Creating Logfiles for Upshot, Next: Examining Log Files with Upshot
  2078.  
  2079.  
  2080. User-Specified Events
  2081. ---------------------
  2082.  
  2083.  
  2084.  
  2085. The ALOG package consists of a set of macros that can be used to instrument a
  2086. C program and a set of functions that can be used to instrument a Fortran
  2087. program.  We will focus here primarily on the use of the C interface, which
  2088. contains more functionality.
  2089.  
  2090. The macros that can be used to instrument a program are as follows (from the 
  2091. file `README_ALOG' in the `alog' directory):
  2092.  
  2093.  
  2094.      ALOG_SETUP(pid,flag):    
  2095.        pid  -  (integer) process id of callee
  2096.        flag -  (integer) either ALOG_WRAP or ALOG_TRUNCATE  
  2097.  
  2098. This macro initializes the tracing area for a slave process and must be called
  2099. once before any event is logged.  If the value of `flag' is set to
  2100. `ALOG_WRAP', then in the event of no more space for logging events the
  2101. system will only report the latest n events.  If `flag' is set to
  2102. `ALOG_TRUNCATE' the system will stop logging events as soon as there is
  2103. no more memory for the events to be logged.
  2104.  
  2105.  
  2106.      ALOG_MASTER(pid,flag):
  2107.        pid  -  (integer) process id of the callee
  2108.        flag -  (integer) either 0 or 1  (see above)
  2109.  
  2110. `ALOG_SETUP' with the difference that this macro should be referenced by
  2111. the master process only.
  2112.  
  2113.  
  2114.      ALOG_DEFINE(event,strdef,format):
  2115.        event  - (integer) id of event being defined
  2116.        strdef - (string) description of 'event'
  2117.        format - (string) control string in "printf" format to
  2118.  
  2119. This macro puts an event definition code into the logfile.
  2120.  
  2121.  
  2122.      ALOG_LOG(pid,event,intdata,strdata):
  2123.        pid     - (integer) process id of callee
  2124.        event   - (integer) event id to be logged
  2125.        intdata - (integer) any integer data for this event
  2126.        strdata - (string) any string data (can be the null string)
  2127.  
  2128. This macro provides the event logging service.
  2129.  
  2130.  
  2131.      ALOG_OUTPUT
  2132.        no parameters  
  2133.  
  2134. This macro dumps the events logged into a log file with the name
  2135. `alogfile.pxx' where `xx' is the logical PID of the callee process.
  2136. The log file is created in the current directory unless specified otherwise
  2137. through the macro ALOG_SETDIR.
  2138.  
  2139.  
  2140.      ALOG_SETDIR(dir)
  2141.        dir - (string) directory where log file is created
  2142.  
  2143. This macro sets the output directory for the log file.  The default directory
  2144. for the creation of the log file is the current directory of the process.  If
  2145. used, then this macro MUST be invoked before `ALOG_MASTER/ALOG_SETUP'.
  2146.  
  2147.  
  2148.      ALOG_STATUS(status):
  2149.        status - (integer) either ALOG_ON or ALOG_OFF
  2150.  
  2151.  
  2152. This macro controls the logging status of `ALOG' as follows.  Setting
  2153. `status' to `ALOG_ON' enables logging until it is turned off.
  2154. Setting `status' to `ALOG_OFF' disables logging until it is turned
  2155. on again.  Logging is enabled at the outset by default.
  2156.  
  2157.  
  2158.  
  2159.      ALOG_ENABLE
  2160.        no parameters
  2161.  
  2162.  
  2163. This macro enables event logging; same as calling `ALOG_STATUS(ALOG_ON)'.
  2164.  
  2165.  
  2166.      ALOG_DISABLE
  2167.        no parameters
  2168.  
  2169. This macro disables event logging; same as calling
  2170. `ALOG_STATUS(ALOG_OFF)'.
  2171.  
  2172. The sample program `gridlog.shmem.c' in the `monitors' subdirectory
  2173. contains an example of a program instrumented with ALOG statements.  The macro
  2174. definitions for ALOG are included when you include `#include "p4"' in
  2175. your program.  If the line `#define ALOG_TRACE' is not included before
  2176. the `#include "p4"', these macros will generate no code.  Thus it is
  2177. easy to effectively de-instrument the code by recompiling, and there is no
  2178. need to protect each ALOG statement with an `#ifdef'.
  2179.  
  2180. When an ALOG-instrumented program is run, it will produce one logfile for each
  2181. process.  The files will be named `alogfile.p0', `alogfile.p1',
  2182. .  These files need to be merged into a single file with the events
  2183. sored by timestamp.  This is accomplished with the program `mergelogs',
  2184. found in the `bin' subdirectory.  To merge the logfiles, do 
  2185.  
  2186.      mergelogs alogfile.p* > myprog.log
  2187.      rm alogfile.p*
  2188.  
  2189.  
  2190. The resulting logfile can be examined by upshot or some other logfile
  2191. examination facility.  See [herrarte-lusk:upshot] for details of the
  2192. logfile format.
  2193.  
  2194. On networks of workstations and some distributed memory machisnes, the
  2195. microsecond timers on the various processors are synchronized.  To produce a
  2196. usable merged logfile, the `adjlogs' program, also found in the
  2197. `bin' directory, can be used to adjust the timestamps for offset and
  2198. drift before they are merged.  For this to work, synchronization events must
  2199. be placed in the logfiles by an `ALOG_LOG' statement.  The event type
  2200. is then passed to `adjlogs', which aligns the timestamps, based on the
  2201. timestamps of the synchonization events.  The call to `adjlogs' looks
  2202. like this, where `<n>' is the type of the synchronization event.
  2203.  
  2204.      adjlogs -e <n>
  2205.  
  2206.  
  2207. Both `mergelogs' and `adjlogs' are less portable than the other p4
  2208. code;  you might want to run them on a workstation such as a Sun.
  2209.  
  2210. 
  2211. File: p4.info  Node: Examining Log Files with Upshot, Prev: User-Specified Events, Up: Creating Logfiles for Upshot, Next: Automatic Logging of p4 Events
  2212.  
  2213.  
  2214. Examining Log Files with Upshot
  2215. -------------------------------
  2216.  
  2217.  
  2218.  
  2219.  
  2220. `Upshot' is not part of the p4 distribution, but can be obtained from the
  2221. same anonymous `ftp' location as p4.  Take the file `upshot.tar.Z'
  2222. from the directory `pub/p4' on `info.mcs.anl.gov'.  The distribution
  2223. contains all necessary documentation on how to install and run `upshot'.
  2224. It is an X-window program that runs on most workstations.  There is no need
  2225. for a parallel macchine to be involved, once the log files have been obtained.
  2226.  
  2227. `Upshot' produces the most interesting displays when certain events
  2228. (not necessarily all) are defined to be the entry and exit events for certain
  2229. {states} and then colors are associated with the states.  This association
  2230. is reflected in a {statefile} with a format like the following:
  2231.  
  2232.      1 1 2 red   asking
  2233.      2 3 4 blue  working
  2234.      3 5 6 green updating
  2235.  
  2236.  
  2237. This statefile describes three states.  State 1 is defined to be between
  2238. events 1 and 2.  `Upshot' will color it red and label it "asking".
  2239.  
  2240. 
  2241. File: p4.info  Node: Automatic Logging of p4 Events, Prev: Examining Log Files with Upshot, Up: Creating Logfiles for Upshot, Next:     
  2242.  
  2243.  
  2244. Automatic Logging of p4 Events
  2245. ------------------------------
  2246.  
  2247.  
  2248.  
  2249. We have found that the most useful events to log and study are those
  2250. identified by the user and specified in his program.  That way he can control
  2251. the number of events to be logged and the grain size of the states that are
  2252. represented.  
  2253.  
  2254. In some cases, however, one wants to study the details of the internal
  2255. operation of a p4 application, or get some idea of the behavior on one's
  2256. program without going to the trouble of instrumenting it himself.  To this
  2257. end, p4 itself is instrumented with ALOG statements, although by default they
  2258. are inactive.  To get automatic logging of p4 events (including sending and
  2259. receiving of each message) one needs first to link to a version of the p4
  2260. library that has been compiled with the line `#define ALOG_TRACE'
  2261. uncommented out in the `OPTIONS' file, and secondly, to run with
  2262. `-p4log' on the command line.
  2263.  
  2264. 
  2265. File: p4.info  Node: Machine-Specific Notes, Prev: Creating Logfiles for Upshot, Up: Top, Next: Some Common Problems and their Solutions
  2266.  
  2267.  
  2268. Machine-Specific Notes
  2269. ======================
  2270.  
  2271.  
  2272.      SUN
  2273.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2274.      
  2275.      HP
  2276.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2277.          (2)  Fortran not tested (not avail on our test machine).
  2278.      
  2279.      DEC5000
  2280.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2281.      
  2282.      RS6000
  2283.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2284.      
  2285.      IBM3090
  2286.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2287.          (2)  Fortran not supported due to absence of iargc/getarg.
  2288.          (3)  There are multiply defined macros in include/rpc/rpc.h.  IBM
  2289.               is fixing this in a later OS release.  Meanwhile make your own
  2290.               copy and the fix the problem yourself.
  2291.          
  2292.      TITAN
  2293.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2294.          (2)  Fortran not supported due to problems with getting args.
  2295.      
  2296.      SGI
  2297.          (1)  P4 can be installed on this machine with or without SYSV IPC.
  2298.      
  2299.      NEXT
  2300.          (1)  Fortran not supported due to absence of iargc/getarg.
  2301.      
  2302.      FX2800/FX2800_SWITCH
  2303.          (1)  Alliant's switch code not yet ensuring messages 
  2304.               remain ordered.  p4 currently discovers the switch port for
  2305.               the machine it is running on by invoking the internal
  2306.               procedure getswport.  This procedure must be customized to
  2307.               the installation.
  2308.            
  2309.      FX8
  2310.          (1)  You might need to add MFLAGS = -i to the Makefile
  2311.      
  2312.      KSR
  2313.          (1)  The latest version of the OS produces a link-time error for
  2314.               Fortran programs.
  2315.      
  2316.      IPSC860
  2317.          (1)  the script "runcube" (in the messages directory) may 
  2318.               be useful
  2319.           
  2320.      DELTA
  2321.          (1)  the script "rundelta" (in the messages directory) may 
  2322.               be useful
  2323.      
  2324.      BALANCE
  2325.          (1)  Fortran not supported.
  2326.      
  2327.      SYMMETRY/SYMMETRY_PTX
  2328.          (1)  -Z compiler option may be used to control shmalloc/malloc split
  2329.          (2)  shared memory message passing not supported in Fortran
  2330.      
  2331.      TC_2000/TC_2000_TCMP
  2332.          (1)  TCMP port not yet complete.
  2333.          (2)  For shared-memory execution, one must use `cluster ...' to
  2334.               obtain a private cluster for execution
  2335.  
  2336.  
  2337. 
  2338. File: p4.info  Node: Some Common Problems and their Solutions, Prev: Machine-Specific Notes, Up: Top, Next: Concept Index
  2339.  
  2340.  
  2341. Some Common Problems and their Solutions
  2342. ========================================
  2343.  
  2344.  
  2345.  
  2346.  
  2347. Our attempt with this manual has been to prevent you from having difficulties.
  2348. Experience shows that certain common progblems recur, however.  In this
  2349. section we hope to address some of these problems.
  2350.  
  2351. "Permission Denied."     
  2352.       p4 slave processes are started by forks (for
  2353.        slaves in the same shared-memory cluster), by the server, or by the remote
  2354.        shell command.  If the server is running on the target machine then that
  2355.        must be configured to allow remote processes to be started.  To test whether
  2356.        this is your problem, try
  2357.               rsh target.machine date
  2358.      
  2359.        If you still get the "Permission denied." message, then the problem has
  2360.        nothing to do with p4.  See `hosts.equiv' or `.rhosts' in the
  2361.        system man pages.
  2362. "More processes than message queues"     
  2363.        Under the default configuration
  2364.        of p4, uniprocessors, such as most workstations, cannot have multiple
  2365.        process sharing memory.  Thus your procgroup file for a workstation network
  2366.        should always look like
  2367.               local 0
  2368.               machine1 1 pathname
  2369.               machine2 1 pathname
  2370.               machine3 1 pathname
  2371.                  .
  2372.                  .
  2373.      
  2374.        The "local" means "only the master on the startup machine; no local
  2375.        slaves sharing memory".
  2376.      
  2377.      
  2378.        It is possible, at some cost in message-passing efficiency, to have a
  2379.        cluster of processes sharing memory on a workstation, but in this case p4
  2380.        must have been installed with the `SYSV_IPC' option set in the
  2381.        `OPTIONS' file.  The cost is that a process waiting for a message must
  2382.        spin between checking for a message arriving on a socket and a message
  2383.        arriving through shared memory. 
  2384.      
  2385. "p4error: local is not first entry in procgroup"     
  2386.        the first line of
  2387.        the procgroup file must be the "local" entry, specifying the number of
  2388.        slaves that will be run on the master machine in addition to the master
  2389.        process. 
  2390.      
  2391. "gethostbyname failed 100 times"     
  2392.       Check for an invalid machine name in
  2393.        the procgroup file.
  2394. "pgmpathname: Command not found"     
  2395.        P4 tried to start the program
  2396.        with the given name on a remote machine and the program did not exist.
  2397.        Verify the full path name of the program.
  2398. program hangs     
  2399.        You may have failed to initialize the `type' and
  2400.        `from' fields before a `p4_recv'.  You might have used
  2401.        `p4_sendr' between two processes at the same time, which will deadlock
  2402.        if you think about it, or even if you don't.  Use `p4_send' instead.
  2403. program hangs or has bad data in received message     
  2404.        You might have
  2405.        failed to set the pointer to the incoming buffer to NULL, or to have
  2406.        specifically allocated a buffer with `p4_msg_alloc', before a
  2407.        `p4_recv'.
  2408. program ignores command-line arguments     
  2409.        You might have passed
  2410.        `argc' instead of `&argc' to `p4_initenv'.
  2411. program runs out of memory     
  2412.        You may need to call `p4_msg_free'
  2413.        after each `p4_recv', or reuse buffers by pre-allocating them.
  2414.      
  2415.      
  2416.  
  2417.  
  2418. 
  2419. File: p4.info  Node: Concept Index, Prev: Some Common Problems and their Solutions, Up: Top, Next: Function Index
  2420.  
  2421.  
  2422. Concept Index
  2423. =============
  2424.  
  2425.  
  2426. * Menu:
  2427.  
  2428. * allocating buffers: Explicit Sending and Receiving of Messages.
  2429. * askfor monitor: Some Useful Monitors.
  2430. * automatic logging: Automatic Logging of p4 Events.
  2431. * barrier: Global Operations.
  2432. * barrier: Some Useful Monitors.
  2433. * buffer pool management: Miscellaneous Functions.
  2434. * clocks: Functions for Timing p4 Programs.
  2435. * cluster management: Functions for Cluster Management.
  2436. * command-line arguments: Command-Line Arguments.
  2437. * data types for monitors: Shared Memory Data Types.
  2438. * deallocating buffers: A More Complicated Example.
  2439. * deallocating buffers: Explicit Sending and Receiving of Messages.
  2440. * debugging: Functions for Debugging p4 Programs.
  2441. * directory structure: Structure of the Distribution Directory.
  2442. * documentation: Installing the Documentation.
  2443. * emacs Info: Installing the Documentation.
  2444. * examples: Examples included with the Distribution.
  2445. * faster startup: Faster Startup with the Secure Server.
  2446. * Fortran interface: Fortran Interface.
  2447. * getting started: Getting Started.
  2448. * global operations: Global Operations.
  2449. * installation: Installing p4.
  2450. * interrupts: Functions for Debugging p4 Programs.
  2451. * IPC: Some Common Problems and their Solutions.
  2452. * lock: Some Useful Monitors.
  2453. * logging: Creating Logfiles for Upshot.
  2454. * machines: Installing the p4 System.
  2455. * man pages: Installing the Documentation.
  2456. * message-passing functions: Functions for Message Passing.
  2457. * monitor data types: Shared Memory Data Types.
  2458. * monitor primitives: Monitor-Building Primitives.
  2459. * monitors: Some Useful Monitors.
  2460. * online help: Installing the Documentation.
  2461. * OPTIONS: Structure of the Distribution Directory.
  2462. * permission denied: Some Common Problems and their Solutions.
  2463. * permissions: Faster Startup with the Secure Server.
  2464. * problems: Some Common Problems and their Solutions.
  2465. * process management: Functions for Process Management.
  2466. * procgroup files: Specifying Processes in the Procgroup File.
  2467. * receiving messages: Explicit Sending and Receiving of Messages.
  2468. * return codes: Return Codes from p4 Functions.
  2469. * rhosts: Faster Startup with the Secure Server.
  2470. * runaway processes: Functions for Debugging p4 Programs.
  2471. * sending messages: Explicit Sending and Receiving of Messages.
  2472. * servers: Faster Startup with the Secure Server.
  2473. * servers: Utilities for Managing a p4 Session.
  2474. * shared memory data types: Shared Memory Data Types.
  2475. * shared memory functions: Functions for Shared Memory.
  2476. * slave subroutine: A Minimal Example.
  2477. * statefile: Examining Log Files with Upshot.
  2478. * testing: Installing the p4 System.
  2479. * timestamps: Creating Logfiles for Upshot.
  2480. * timing: Functions for Timing p4 Programs.
  2481. * tracefiles: Creating Logfiles for Upshot.
  2482. * unlock: Some Useful Monitors.
  2483. * upshot: Creating Logfiles for Upshot.
  2484. * upshot: Examining Log Files with Upshot.
  2485. * user events: User-Specified Events.
  2486. * utilities: Utilities for Managing a p4 Session.
  2487.  
  2488.  
  2489.  
  2490. 
  2491. File: p4.info  Node: Function Index, Prev: Concept Index, Up: Top, Next:     
  2492.  
  2493.  
  2494. Function Index
  2495. ==============
  2496.  
  2497.  
  2498.  
  2499. * Menu:
  2500.  
  2501. * ALOG_DEFINE: User-Specified Events.
  2502. * ALOG_DISABLE: User-Specified Events.
  2503. * ALOG_ENABLE: User-Specified Events.
  2504. * ALOG_LOG: User-Specified Events.
  2505. * ALOG_MASTER: User-Specified Events.
  2506. * ALOG_OUTPUT: User-Specified Events.
  2507. * ALOG_SETDIR: User-Specified Events.
  2508. * ALOG_SETUP: User-Specified Events.
  2509. * ALOG_STATUS: User-Specified Events.
  2510. * p4_alloc_procgroup: Functions for Process Management.
  2511. * p4_am_i_cluster_master: Functions for Cluster Management.
  2512. * p4_askfor: Some Useful Monitors.
  2513. * p4_askfor_init: Some Useful Monitors.
  2514. * p4_barrier: Some Useful Monitors.
  2515. * p4_barrier_init: Some Useful Monitors.
  2516. * p4_broadcast: Global Operations.
  2517. * p4_broadcastx: Global Operations.
  2518. * p4_clock: Functions for Timing p4 Programs.
  2519. * p4_create: Functions for Process Management.
  2520. * p4_create_procgroup: Functions for Process Management.
  2521. * p4_dprintf: Functions for Debugging p4 Programs.
  2522. * p4_dprintfl: Functions for Debugging p4 Programs.
  2523. * p4_error: Functions for Debugging p4 Programs.
  2524. * p4_free: Managing Shared and Local Memory.
  2525. * p4_get_cluster_ids: Functions for Cluster Management.
  2526. * p4_get_cluster_masters: Miscellaneous Functions.
  2527. * p4_get_dbg_level: Functions for Debugging p4 Programs.
  2528. * p4_get_my_cluster_id: Functions for Cluster Management.
  2529. * p4_get_my_id: Functions for Process Management.
  2530. * p4_getsub: Some Useful Monitors.
  2531. * p4_getsub_init: Some Useful Monitors.
  2532. * p4_getsubs: Some Useful Monitors.
  2533. * p4_global_barrier: Global Operations.
  2534. * p4_global_op: Global Operations.
  2535. * p4_initenv: Functions for Process Management.
  2536. * p4_lock: Some Useful Monitors.
  2537. * p4_lock_init: Some Useful Monitors.
  2538. * p4_malloc: Managing Shared and Local Memory.
  2539. * p4_mcontinue: Monitor-Building Primitives.
  2540. * p4_mdelay: Monitor-Building Primitives.
  2541. * p4_menter: Monitor-Building Primitives.
  2542. * p4_messages_available: Explicit Sending and Receiving of Messages.
  2543. * p4_mexit: Monitor-Building Primitives.
  2544. * p4_moninit: Monitor-Building Primitives.
  2545. * p4_msg_alloc: Explicit Sending and Receiving of Messages.
  2546. * p4_msg_free: Explicit Sending and Receiving of Messages.
  2547. * p4_num_cluster_ids: Functions for Cluster Management.
  2548. * p4_num_total_ids: Functions for Process Management.
  2549. * p4_num_total_slaves: Functions for Process Management.
  2550. * p4_print_avail_buffs: Miscellaneous Functions.
  2551. * p4_probend: Some Useful Monitors.
  2552. * p4_progend: Some Useful Monitors.
  2553. * p4_recv: Explicit Sending and Receiving of Messages.
  2554. * p4_send: Explicit Sending and Receiving of Messages.
  2555. * p4_sendb: Explicit Sending and Receiving of Messages.
  2556. * p4_sendbr: Explicit Sending and Receiving of Messages.
  2557. * p4_sendbrx: Explicit Sending and Receiving of Messages.
  2558. * p4_sendbx: Explicit Sending and Receiving of Messages.
  2559. * p4_sendr: Explicit Sending and Receiving of Messages.
  2560. * p4_sendrx: Explicit Sending and Receiving of Messages.
  2561. * p4_sendx: Explicit Sending and Receiving of Messages.
  2562. * p4_set_avail_buff: Miscellaneous Functions.
  2563. * p4_set_dbg_level: Functions for Debugging p4 Programs.
  2564. * p4_shfree: Managing Shared and Local Memory.
  2565. * p4_shmalloc: Managing Shared and Local Memory.
  2566. * p4_soft_errors: Functions for Debugging p4 Programs.
  2567. * p4_startup: Functions for Process Management.
  2568. * p4_unlock: Some Useful Monitors.
  2569. * p4_update: Some Useful Monitors.
  2570. * p4_usrollover: Functions for Timing p4 Programs.
  2571. * p4_ustimer: Functions for Timing p4 Programs.
  2572. * p4_version: Miscellaneous Functions.
  2573. * p4_wait_for_end: Functions for Process Management.
  2574.  
  2575.  
  2576.  
  2577.  
  2578. 
  2579. Tag table:
  2580. Node: Top94
  2581. Node: Introduction920
  2582. Node: Structure of the Distribution Directory4274
  2583. Node: Installing p46105
  2584. Node: Installing the p4 System6906
  2585. Node: Installing the Documentation9890
  2586. Node: Examples included with the Distribution11100
  2587. Node: Getting Started11908
  2588. Node: A Message-Passing Example12243
  2589. Node: Analysis of the Program13437
  2590. Node: Specifying Processes in the Procgroup File15976
  2591. Node: Developing a Simple p4 Program20514
  2592. Node: A Minimal Example21050
  2593. Node: A More Complicated Example24028
  2594. Node: Command-Line Arguments30347
  2595. Node: The p4 Function Library31144
  2596. Node: Overview of the Library31412
  2597. Node: Return Codes from p4 Functions31989
  2598. Node: p4 Functions for Managing Processes and Clusters32435
  2599. Node: Functions for Process Management33356
  2600. Node: Functions for Cluster Management38492
  2601. Node: Functions for Message Passing40224
  2602. Node: Explicit Sending and Receiving of Messages41038
  2603. Node: Global Operations45306
  2604. Node: Functions for Shared Memory47866
  2605. Node: Managing Shared and Local Memory48199
  2606. Node: Shared Memory Data Types48975
  2607. Node: Monitor-Building Primitives49652
  2608. Node: Some Useful Monitors51353
  2609. Node: Functions for Timing p4 Programs56823
  2610. Node: Functions for Debugging p4 Programs57897
  2611. Node: Miscellaneous Functions63665
  2612. Node: Fortran Interface65550
  2613. Node: Faster Startup with the Secure Server67024
  2614. Node: Utilities for Managing a p4 Session70122
  2615. Node: Creating Logfiles for Upshot70799
  2616. Node: User-Specified Events71930
  2617. Node: Examining Log Files with Upshot76842
  2618. Node: Automatic Logging of p4 Events78011
  2619. Node: Machine-Specific Notes79062
  2620. Node: Some Common Problems and their Solutions81601
  2621. Node: Concept Index84958
  2622. Node: Function Index87958
  2623. 
  2624. End tag table
  2625.